summaryrefslogtreecommitdiff
path: root/tests/stack-test.lisp
blob: cabbaa3209e381486f7f43c7b13e3a37143700fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
(define g (x) (+ x 1))

(define f (x)
    (if (<= x 0)
        0
        (let ((y (g x)))
            (+ y (f (/ x 2))))))

; f 10
; = 11 + f 5
; = 11 + 6 + f 2
; = 11 + 6 + 3 + f 1
; = 11 + 6 + 3 + 2
; = 22
(print (f 10))

; Without Stackify, the deepest y value, i.e. 2, overwrites all y values above,
; resulting in 2 + 2 + 2 + 2 = 8.