As for my article "Cheat Sheet", as the number of supported languages and supplementary notes increased, it became a commentary article rather than a cheat sheet. Created a list of description examples. After a while, the original article title may be changed to "Currying Description Summary" and this may be changed to "Currying Cheat Sheet".
For languages that can use multiple notations, only the shortest writing method is posted when the latest version and currying method are not used. For other differences due to notation and version, see Original article.
language | (λxy.(true, if x>y;and fake, if x≦y)) 10 20 |
---|---|
Haskell | (\x y -> x > y) 10 20 |
Scheme | (((lambda (x) (lambda (y) (> x y))) 10) 20) |
Python | (lambda x: lambda y: x > y)(10)(20) |
Ruby | -> x { -> y { x > y } }[10][20] |
JavaScript | (x => y => x > y)(10)(20) |
Scala | ((x: Int) => (y: Int) => x > y)(10)(20) |
Perl | sub { my $x = shift; return sub { my $y = shift; return $x > $y }; }->(10)->(20) |
Go language | func(x int) func(int) bool { return func(y int) bool { return (x > y) } }(10)(20) |
PHP | (fn($x) => fn($y) => $x > $y)(10)(20) |
Julia | (x -> y -> x > y)(10)(20) |
Emacs Lisp, Common Lisp | (funcall (funcall (lambda (x) (lambda (y) (> x y))) 10) 20) |
R language | (function(x) { function(y) { x > y } })(10)(20) |
Recommended Posts