GNU Free Documentation License . .

Scheme

: ,
Scheme
Lambda lc.svg
:

:

:

1970

():

:

.scm, .ss

:

,

:

PLT Scheme, MIT Scheme, Scheme48, Guile, JScheme

:

T (.)

:

Lisp, ALGOL

:

Common Lisp, JavaScript, R, Ruby, Dylan, Lua, Hop (.)., Racket (.).

Scheme  , (   Common Lisp). Scheme  (. Guy L. Steele) (. Gerald Jay Sussman)   1970- .

[]

Scheme . .   ,   , . , Scheme , . , 2 :

  1. ,
  2. ( ).

Scheme , « », « ». Scheme , ( ) , (#t #f T NIL). , . R^5RS, « » (. hygienic macro). Scheme « », .

(«»). , () ,   , .

, , Schemer - ITS.

[]

[]

(+ 2 (* 2 2))
(+ 1 2 3 4)

( ) , (, , ) .

[]

(number? 5)
(number? "foo")
(string? "foo")

, ?.

[]

(equal? "foo" "bar")
(eqv? 5 (+ 2 3))
(eq? 'a 'A)

[] push/pop

(define-syntax push!
  (syntax-rules ()
    ((push! x l)
     (set! l (cons x l)))))
 
(define-syntax pop!
  (syntax-rules ()
    ((pop! l)
     (let ((x (car l)))
       (set! l (cdr l))
       x))))

[]

;;   ()  
(define (fact x)
  (if (< x 3)
      x
      (* (fact (- x 1)) x)))
 
;;      
(define (fib n)
  (cond ((= n 0) 0)
        ((= n 1) 1)
        (else (+ (fib (- n 1))
                 (fib (- n 2))))))
 
;;       Scheme 
;; (  loop    
;;    -)
(define (sum-list x)
  (let loop ((x x) (n 0))
    (if (null? x)
        n
        (loop (cdr x) (+ (car x) n)))))
 
(fact 14)
(fib 10)
(sum-list '(6 8 100))
(sum-list (map fib '(1 2 3 4)))

:

(define - (lambda () (-)))

:

(define (- ) (-))

[] /

(write (+ (read) (read)))

[]

[] .

[]