Scheme ![]() |
ähnliche Sprachen: | Lisp | |
Beschreibung: | Eine Lisp-ähnliche Sprache. |
Fakultät | Michael Neumann |
; define function (define fak (lambda (n) (if (< n 2) 1 (* n (fak (- n 1))) ) ) ) ; call function (fak 6) |
Berechnet die Fakultät. Ergibt
720 . |
Hello World (1) | Michael Neumann |
; Hello World in Scheme (display "Hello World") |
Gibt "Hello World" auf dem Bildschirm
aus. |
Hello World (2) | J. A. Durieux |
; Hello World "Hello, world!" |
Gibt "Hello World" auf dem Bildschirm
aus. |
Squares (1) | Michael Neumann |
(do ; Initialize variables ( (i 1 (+ i 1)) ) ; while condition ( (> i 10) ) ; loop body (display (* i i)) (display " ") ) |
Gibt die Quadrate von 1 bis 10
aus. |
Squares (2) | J. A. Durieux |
; Squares
(define (squares from to)
(if (> from to) '()
(cons (* from from)
(squares (+ from 1) to) ) ) )
(squares 0 10)
|
Gibt die Quadrate von 1 bis 10
aus. |