1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| let curry = require("rambda").curry let compose = require("rambda").compose let add = curry((a, b) => a + b) let match = curry((regex, str) => str.match(regex)) let replace = curry((regex, replacement, str) => str.replace(regex, replacement) ) let filter = curry((f, arr) => arr.filter(f)) let map = curry((f, arr) => arr.map(f)) let split = curry((symbol, str) => str.split(symbol)) let reduce = curry((f, arr, x) => x.reduce(f, arr)) let join = curry((symbol, arr) => arr.join(symbol)) let toUppercase = curry((str) => str.toUpperCase()) let toLowercase = curry((str) => str.toLowerCase())
var words = split(" ") words("hello world !")
var theWords = map(words) theWords(["first message", "seconde message"])
var filterAString = filter(match(/a/i)) filterAString(["quick", "queue", "apple", "two"])
var _max = (a, b) => (a >= b ? a : b)
var max = reduce(_max, -Infinity) max([1, 2, 3, 4])
|