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

proof that lisp is a toy language

Name: Anonymous 2007-10-25 9:25

it can't even do this:
function fib(n){
 return (function(i){
   return i==1?0:arguments.callee(i-1)+(function(i){
    return i==1?1:arguments.callee.caller(i-1)
   })(i-1)
  })(n+1)
}

Name: Anonymous 2007-10-25 12:16

(define *callers* '())

(define (call f . args)
  (fluid-let ((*callers* (cons f *callers*)))
    (apply f args)))

(define (fib n)
  (call (lambda (i)
          (if (= i 1)
              0
              (+ (call (car *callers*) (- i 1))
                 (call (lambda (i)
                         (if (= i 1)
                             1
                             (call (cadr *callers*) (- i 1))))
                       (- i 1)))))
        (+ n 1)))

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