This page is under reformatting from contents of algobit wiki / Comparison.
| abstraction\language | Haskell | Scheme | Common Lisp | Clojure | JavaScript | Scala | Ocaml | F# | 
|---|---|---|---|---|---|---|---|---|
Function Literal  | 
(\x y -> x^2 + y^2) 3 4 -- -> 25  | 
((lambda (x y) (+ (* x x) (* y y))) 3 4) ; -> 25  | 
((lambda (x y) (+ (* x x) (* y y))) 3 4) ; -> 25  | 
((fn [x y] (+ (* x x) (* y y))) 3 4) ; -> 25  | 
function (x, y) { return x*x + y*y; } (3, 4); // -> 25  | 
((x:Int, y:Int) => x*x + y*y)(3, 4) // -> Int = 25  | 
(fun x y -> x*x + y*y) 3 4;; (* -> int = 25 *)  | 
(fun x y -> x*x + y*y) 3 4;; (* -> int = 25 *)  | 
bind a function literal to a variable  | 
sos = (\x y -> x^2 + y^2) sos 3 4 -- -> 25(*1)  | 
(define sos (lambda (x y) (+ (* x x) (* y y)))) (sos 3 4) ; -> 25  | 
(setq sos (lambda (x y) (+ (* x x) (* y y)))) (funcall sos 3 4) ; -> 25  | 
(def sos (fn [x y] (+ (* x x) (* y y)))) (sos 3 4) ; -> 25  | 
var sos = function (x, y) { return x*x + y*y; }; sos(3, 4); // -> 25  | 
var sos (x:Int, y:Int) => x*x + y*y sos(3, 4) // -> Int = 25  | 
let sos = fun x y -> x*x + y*y;; sos 3 4;; (* -> int = 25 *)  | 
let sos = fun x y -> x*x + y*y;; sos 3 4;; (* -> int = 25 *)  | 
bind a function literal to a variable in a lexical scope  | 
let sos = (\x y -> x^2 + y^2) in sos 3 4 -- -> 25 sos 3 4 -- -> Not in scope: 'sos'  | 
(let ((sos (lambda (x y) (+ (* x x) (* y y))))) (sos 3 4)) ; -> 25 (sos 3 4) ; -> unbound variable: sos  | 
(let ((sos (lambda (x y) (+ (* x x) (* y y))))) (funcall sos 3 4)) ; -> 25 (funcall sos 3 4) ; -> The variable SOS is unbound  | 
(let [sos (fn [x y] (+ (* x x) (* y y)))] (sos 3 4)) ; -> 25 (sos 3 4) ; -> Unable to resolve symbol: sos  | 
function () { var sos = function (x, y) { return x*x + y*y; }; return sos(3, 4); }(); // -> 25 sos(3, 4) // -> sos is not defined  | 
(() => var sos (x:Int, y:Int) => x*x + y*y sos(3, 4) )() // -> Int = 25 sos(3, 4) // -> not found: value sos  | 
let sos = fun x y -> x*x + y*y in sos 3 4;; (* -> int = 25 *) sos 3 4;; (* -> Unbound value sos *)  | 
let sos = fun x y -> x*x + y*y in sos 3 4;; (* -> int = 25 *) sos 3 4;; (* -> The value or constructor 'sos' is not defined *)  | 
declare a named function  | 
sos = (\x y -> x^2 + y^2) sos 3 4 -- -> 25(*1)  | 
(define (sos x y) (+ (* x x) (* y y))) (sos 3 4) ; -> 25  | 
(defun sos (x y) (+ (* x x) (* y y))) (sos 3 4) ; -> 25  | 
(defn sos [x y] (+ (* x x) (* y y))) (sos 3 4) ; -> 25  | 
function sos(x, y) { return x*x + y*y; }; sos(3, 4); // -> 25  | 
def sos(x:Int, y:Int) x*x + y*y sos(3, 4) // -> 25  | 
let sos = fun x y -> x*x + y*y;; sos 3 4;; (* -> int = 25 *)  | 
let sos = fun x y -> x*x + y*y;; sos 3 4;; (* -> int = 25 *)  | 
a named function in a lexical scope  | 
let sos x y = x^2 + y^2 in sos 3 4 -- -> 25 sos 3 4 -- -> Not in scope: `sos'  | 
((lambda () (define (sos x y) (+ (* x x) (* y y))) (sos 3 4))) ; -> 25 (sos 3 4) ; -> unbound variable: sos  | 
(labels ((sos (x y) (+ (* x x) (* y y)))) (sos 3 4)) ; -> 25 (sos 3 4) ; -> undefined function  | 
(letfn [(sos [x y] (+ (* x x) (* y y)))] (sos 3 4)) ; -> 25 (sos 3 4) ; -> Unable to resolve symbol: sos  | 
function () { function sos(x, y) { return x*x + y*y; } return sos(3, 4); }(); // -> 25 sos(3, 4); // -> sos is not defined  | 
(() => def sos(x:Int, y:Int) x*x + y*y sos(3, 4) )() // -> Int = 25 sos(3, 4) // -> not found: value sos  | 
let sos x y = x*x + y*y in sos 3 4;; (* -> int = 25 *) sos 3 4;; (* -> Unbound value sos *)  | 
let sos x y = x*x + y*y in sos 3 4;; (* -> int = 25 *) sos 3 4;; (* -> The value or constructor 'sos' is not defined *)  | 
Y.Kohyama