#;31> (define rec itrec)
#;32> ((rec zero? 1 * sub1) 6)
Error: during expansion of (letrec ...) - (letrec) unexpected object:
((zero? 1 * sub1))
#;32> (eq? rec itrec)
#t
#;33> ((rec zero? 1 * sub1) 6)
Error: during expansion of (letrec ...) - (letrec) unexpected object:
((zero? 1 * sub1))
#;33> ((itrec zero? 1 * sub1) 6)
720
#;34> 

itrec and rec are the same, but one makes error and the other doesn't.
csi -version
Version 2, Build 214 - linux-unix-gnu-unknown - [ dload ptables ]

Chicken and csi is from darcs repo a couple of days ago.

; This is the definition of itrec

(define (itrec break start do inc)
  (lambda (x)
    (let loop ((x x) (total start))
      (if (break x)
          total
          (loop (inc x) (do x total))))))

;; and this is the definition of rec that I originally wanted to have,
;; but the behaviour is as crazy regardless of what rec does.
;; even with (define rec itrec) it becomes crazy!
;; or with (define rec list) or define rec anything, anything!

(define (rec break fin do inc)
  (lambda (x)
    (let loop ((x x))
      (if (break x)
          fin
          (do x (loop (inc x)))))))


I wanted to make an implementation of the idea in near the bottom of
http://www.paulgraham.com/power.html

help!
years truely,
sunnan



_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to