Haskell Prelude Like Functions Implemented In JavaScript


Prelude's functions

A: abs, all, and, any, atan
B: hbreak
C: ceiling, chr, compare, hconcat, concatMap, hconst, cos
D: digitToInt, div, drop, dropWhile
E: elem, error, even, exp
F: filter, flip, floor, foldl, foldl1, foldr, foldr1, fromInt, fromInteger, fst
G: gcd
H: head
I: id, init, isAlpha, isDigit, isLower, isSpace, isUpper, iterate
L: last, lcm, hlength, lines, log
M: map, max, maximum, min, minimum, mod
N: not, notElem, null
O: odd, or, ord
P: pred, putStr, product
Q: quot
R: rem, repeat, replicate, hreverse, round
S: show, sin, snd, hsort, span, splitAt, sqrt, subtract, succ, sum
T: tail, take, takeWhile, tan, toLower, toUpper, truncate
U: undefined, unlines, until, unwords
W: words
Z: zip, zipWith

Original functions

each, pat, seq

For the time beeing, only functions in bold are available. This script is a freeware. No warranty on it.
Using the JavaScript console of Google Chrome is recommended. Press Shift + Ctrl + J to show the console.

Created by www.mnet.ne.jp/~tnomura or tnomura9.exblog.jp.


map( function(x) {return (x * x)}, [1, 2, 3, 4, 5]) => [1, 4, 9, 16, 25]
seq(1, 10) => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
concatMap(function(y){return map(function(x){return x*x},y)}, [[1,2],[3,4]]) => [1, 4, 9, 16]