Content deleted Content added
No edit summary |
mNo edit summary |
||
Line 29:
== Language Elements ==
=== Comments ===
Comments are preceded by a [[semi-colon]] (;) and continue for the rest of the line.
=== Variables ===
Line 136 ⟶ 140:
(factorial 5)
or a higher order function like ''map'' which applies a function to every element of a list
Line 146 ⟶ 150:
(map (lambda (x) (* x x)) '(1 2 3 4))
;; => (1 4 9 16)
Another way to define loops is the ''named'' <code>
(define (factorial n)
Line 157 ⟶ 161:
(factorial 5)
Line 166 ⟶ 170:
(map (lambda (x) (* x x)) '(1 2 3 4))
Please note that in both cases, the tail recursive version is preferrable.
=== Input/output ===
Scheme has the concept of ''ports'' to read from or to write to. Scheme defines three default ports, accessible with the functions: <code>current-input-port</code>, <code>current-output-port</code> and <code>current-error-port</code>.
|