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

letrec

Name: Anonymous 2011-12-23 12:06

Isn't
(letrec ([is-even? (lambda (n)
                    (or (zero? n)
                        (is-odd? (sub1 n))))]
         [is-odd? (lambda (n)
                   (and (not (zero? n))
                        (is-even? (sub1 n))))])
        (is-odd? 11))


equivalent to...

(let
    ([is-even? nil]
     [is-odd? nil])
    (set! is-even? (lambda (n)
                    (or (zero? n)
                        (is-odd? (sub1 n)))))
    (set! is-odd? (lambda (n)
                   (and (not (zero? n))
                        (is-even? (sub1 n)))))
    (is-odd? 11))

Name: Anonymous 2011-12-23 21:12

What are delimited continuations?
http://dis.4chan.org/read/prog/1135170518/97,101

How are they strictly more expressive than call/cc, without mutable state?
http://www.cs.bham.ac.uk/~hxt/research/exncontjournal.pdf
Basically, given a statically typed lambda calculus without recursion, if we augment it with unchecked exceptions, it will become Turing-complete, but it will not when extended with call/cc, proving that unchecked exceptions are strictly more powerful than call/cc.

You can write a fixpoint combinator with delimited continuations, and implement exceptions without mutable state. Since they're Turing-complete, they're strictly more expressive than call/cc.


(define (fix f)
  (let ((g (lambda (x)
             (control k (f (lambda (y) ((prompt (k values) (k values)) y)))))))
    (prompt (g values) (g values))))

((fix (lambda (fact)
        (lambda (x)
          (if (zero? x) 1
              (* x (fact (- x 1)))))))
 5)
; => 120


I'm going to sleep now. Good night.

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