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

Is this Satori or Zen?

Name: Anonymous 2009-02-01 9:15

CPS in 3 lines of code

(define (apply# f . args) (shift k (let ((g (gensym "g"))) (reset `(,f ,@args (lambda (,g) ,(k g)))))))
(define-syntax if# (syntax-rules () ((if# <cond> <then> <else>) (shift k `(if ,<cond> ,(reset (k <then>)) ,(reset (k <else>)))))))
(define-syntax define# (syntax-rules () ((define# (name/args ...) body) `(define (name/args ... k-->) ,(reset `(k--> ,body))))))


(define# (fact-iter--> n acc)
;;     (if# (apply# 'zero?--> 'n)
;;          'acc
;;          (apply# 'fact-iter--> (apply# '---> 'n 1) (apply# '*--> 'acc 'n))))
(define (fact-iter--> n acc k-->)
  (zero?--> n (lambda (g875)
   (if g875
       (k--> acc)
       (---> n 1 (lambda (g876)
        (*--> acc n (lambda (g877)
         (fact-iter--> g876 g877 (lambda (g878) (k--> g878)))))))))))

Is this Satori or Zen?

Name: Anonymous 2009-02-02 18:30

people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand people who think gotos are like gotos don't understand

(Post truncated.)

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