Content deleted Content added
UserGoogol (talk | contribs) No edit summary |
fix #t vs "true" distinction; partially fix tail recursion exposition |
||
Line 115:
(else exprn))
The first expression for which the test evaluates to true (anything other than #
A variant of the cond clause is
Line 123:
...)
In this case, expr should
Scheme also has
Line 133:
==== Loops ====
Loops in Scheme usually take the form of tail recursion. A classical example is the factorial function, which can be defined non-tail-recursively:
(define (factorial n)
Line 142:
;; => 120
or a higher order function like ''map'' which applies a function to every element of a list, and can be defined non-tail-recursively:
(define (map f lst)
Line 152:
;; => (1 4 9 16)
(define (factorial n)
Line 172:
;; => (1 4 9 16)
Please note that in both cases, the tail recursive version is preferrable due to its decreased use of space.
=== Input/output ===
|