Ctrl + ↑ / Ctrl + ↓. Eval: Ctrl + Enter or the button "eval" below. Source: scheme-on-coffee on Github. ECMAScript info: http://dmitrysoshnikov.com|
Expression input:
Examples (click to eval): 1. Sum: (+ 1 2 3)2. Define a variable in the Global environment: (define x 10)3. Define a procedure:
(define (sum x y)
(+ x y))
4. Eval the sequence (block) of expressions:
(begin (define a 10) ; define "a" variable
(define b 30) ; and "b" variable
(define (square x)
(* x x)) ; and a function
(+ (square a) b)) ; and get the sum of square of "a" and "b"
5. Recursion; define the factorial function and call it:
(begin
(define (factorial n) ; define the factorial function
(if (= n 1)
1
(* n (factorial (- n 1)))))
(factorial 5)) ; and call it for value 5
6. Map the list with a lambda expression:
(map (lambda (x) (* x x)) ; anonymous function
(list 1 2 3 4)) ; maps the list to '(1 4 9 16)
|
Output: |