Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Scheme Programming Language

any one knows how to make a poor man's reduce?


I've just finished SICP mc-eval, and fails the first test,
normal reduction:

(define (normal-reduce f)
  ((lambda (value) (if (equal? value f) f (normal-reduce value)))
   (let r ((f f) (g '()))
     (cond ((not (pair? f))
            (if (null? g) f (if (eq? f (car g)) (cadr g) (r f (caddr
g)))))
           ((and (pair? (car f)) (= 2 (length f)) (eq? 'lambda (caar
f)))
            (r (caddar f) (list (cadar f) (r (cadr f) g) g)))
           ((and (not (null? g)) (= 3 (length f)) (eq? 'lambda (car
f)))
            (cons 'lambda (r (cdr f) (list (cadr f) (delay (cadr f))
g))))
           (else (map (lambda (x) (r x g)) f))))))

car: expects argument of type <pair>; given r

 === context ===
/lfs/scheme/my_eval.sc:318:0: map
/lfs/scheme/my_eval.sc:217:0: let->combination
/lfs/scheme/my_eval.sc:4:0: my-eval
/lfs/scheme/my_eval.sc:45:0: list-of-values
/lfs/scheme/my_eval.sc:4:0: my-eval
/lfs/scheme/my_eval.sc:407:0: driver-loop

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc