Hi all,
FWIIW -- the GCL compiler gives the message it converted the recursion (the Ackerman) into iterations.
Added a few useful (?) macro's .. and seq (seq 6) -> ( 1 ... 6) while range does (0 ... 5) -- normal Lisp indexbase 0.
(this is important when using the sequence as the number of "iterations" of a certain function ) -- i mean, you can not 0 times iterate something : in this case it results in 1/0
example attached : (as an example , because by memoizing a previous result this can be speeded up a very lot - the sequences are recalculated every time ).
----------------------------------------------------------
(define 1+
(lambda (x) (+ 1 x)))
(define 1-
(lambda (x) (- x 1)))
(define println
(lambda (s)
(print s) (newline)))
(define make-listx
(lambda (i x L)
(if (= i x) L
(make-listx (+ i 1) x (cons i L)))))
(define range
(lambda (x)
(reverse (make-listx 0 x '() ))))
(define iterate
(lambda (op it)
(map (eval op) (range it))
T ))
(define seq
(lambda (x)
(reverse (make-listx 1 (1+ x) '() ))))
;;----------------------------tests -- remove from macro.scm
(define 3eta-1
(lambda (x)
(apply + (map (lambda (x) (/ 1 x)) (seq x)))))
(define print3
(lambda (x)
(print (3eta-1 x))
(newline)))
(define tst
(lambda (x)
(map print3 (seq x)) T ))
(define main
(lambda()
(iterate 'newline 10)
(println '"First 50 iterations of Zeta(1)")
(println '"-------------------------------")
(println '" ")
(println '"without memoizing things !")
(newline)
(tst 50)
(newline)
(println '"........finished.........")
))
(main)
--------------------------------------------------------------------------------------------------------
best, Rob
-- forgot, thanks for the LispOS link, John -- unaware about it