Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

continuations

Name: Anonymous 2013-03-02 2:18

In this thread, you may post code that makes use of continuations, and I will attempt to produce code that does the same and looks reasonably similar, without using continuations.

Name: Anonymous 2013-03-03 15:47

>>56
All non deterministic programming can be expressed as deterministic operations on lazy lists that invoke continuations upon evaluation.

Anything that can be done with continuations, can be done with tail recursion in programs that don't use the native stack.

Translating....


(define (fact-normal n)
  (if (= n 0)
    1
    (* n (fact-normal (- n 1)))))


To.....................


(define (fact2 return n)
  (if (= n 0)
    (return 1)
    (fact2 (lambda (ret-val)
             (return (* n ret-val)))
           (- n 1))))

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List