Content deleted Content added
Undid revision 256171866 by 122.162.83.87 (talk) |
Dispelpotion (talk | contribs) m →Examples: schemier |
||
Line 17:
<source lang="scheme">
;; to calculate the product of all non-negative integers
;; less than or
(define factorial
acc▼
(lambda (n)
(fac-times (- n 1) (* acc n))))▼
(if (
(
(
▲ acc
(assertion-violation
'factorial "invalid argument" n))))
</source>
As you can see, the inner procedure <code>
call factorial (3)
call
call
call
call
return 6
return 6
Line 43 ⟶ 47:
call factorial (3)
replace arguments with (3 1), jump to "
replace arguments with (2 3), jump to "
replace arguments with (1 6), jump to "
replace arguments with (0 6), jump to "
return 6
|