chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] crazy behaviour in csi!


From: Sunnan
Subject: [Chicken-users] crazy behaviour in csi!
Date: Mon, 05 Dec 2005 09:33:13 +0100

#;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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]