| Scheme |
| similar languages: | Lisp | |
| Description: | A Lisp-like language. |
| Factorial | Michael Neumann |
; define function (define fak (lambda (n) (if (< n 2) 1 (* n (fak (- n 1))) ) ) ) ; call function (fak 6) |
Calculates the factorial. Results
720. |
| Hello World (1) | Michael Neumann |
; Hello World in Scheme (display "Hello World") |
| Prints "Hello World" onto the
screen. |
| Hello World (2) | J. A. Durieux |
; Hello World "Hello, world!" |
| Prints "Hello World" onto the
screen. |
| Squares (1) | Michael Neumann |
(do
; Initialize variables
(
(i 1 (+ i 1))
)
; while condition
(
(> i 10)
)
; loop body
(display (* i i))
(display " ")
)
|
| Outputs the squares from 1 to
10. |
| Squares (2) | J. A. Durieux |
; Squares
(define (squares from to)
(if (> from to) '()
(cons (* from from)
(squares (+ from 1) to) ) ) )
(squares 0 10)
|
| Outputs the squares from 1 to
10. |