I started Scheme, I'm reading SICP. Finally!
While experimenting with Scheme I came across an error that I cannot explain.
Here's the code:
Here's the output I get:
While experimenting with Scheme I came across an error that I cannot explain.
Here's the code:
(define square (lambda (x)
(* x x)))
(define (loopf N iter f)
(if (not (= iter N))
((write (f iter))
(newline)
(loopf N (+ iter 1) f))))
(loopf 10 0 square)
loopf is supposed to execute procedure f, N times, similar to a C for loop.Here's the output I get:
My question: Why do I get an error at the end of my loop?$ ./scheme ../scripts/loopf.scm
0
1
4
9
16
25
36
49
64
81
Error: (../scripts/fib.scm : 10) illegal function
Errors encountered reading ../scripts/loopf.scm