callCC                 package:base                 R Documentation

_C_a_l_l _W_i_t_h _C_u_r_r_e_n_t _C_o_n_t_i_n_u_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     A downward-only version of Scheme's call with current
     continuation.

_U_s_a_g_e:

     callCC(fun)

_A_r_g_u_m_e_n_t_s:

     fun: function of one argument, the exit procedure.

_D_e_t_a_i_l_s:

     'callCC' provides a non-local exit mechanism that can be useful
     for early termination of a computation.  'callCC' calls 'fun' with
     one argument, an _exit function_.  The exit function takes a
     single argument, the intended return value.  If the body of 'fun'
     calls the exit function then the call to 'callCC' immediately
     returns, with the value supplied to the exit function as the value
     returned by 'callCC'.

_A_u_t_h_o_r(_s):

     Luke Tierney

_E_x_a_m_p_l_e_s:

     # The following all return the value 1
     callCC(function(k) 1)
     callCC(function(k) k(1))
     callCC(function(k) {k(1); 2})
     callCC(function(k) repeat k(1))

