How does (define (sum (x 0)) (inc 0 x)) work?
Posted: Wed Nov 07, 2012 4:26 pm
Hello all...
So I came across this example function in the Code Patterns guide. I'm new to newlisp, so this code is confusing me. How does this function have memory?
I understand that (x 0) means that 0 is a default value for x, what I'm not understanding is why does sum rewrite itself?
I've traced it, and found that after a (sum 4), sum => (lambda ((x 0)) (inc 4 x))... this confuses me.
Any help? Thanks.
So I came across this example function in the Code Patterns guide. I'm new to newlisp, so this code is confusing me. How does this function have memory?
Code: Select all
(define (sum (x 0)) (inc 0 x))
I've traced it, and found that after a (sum 4), sum => (lambda ((x 0)) (inc 4 x))... this confuses me.
Any help? Thanks.