-
Notifications
You must be signed in to change notification settings - Fork 0
API Function
partial : Function -> ...a -> Function
f : Function
...args : Anys
return : Function
Returns f partially applied to ...args.
function plus(x, y) {
return x + y;
}
var plus1 = tlc.partial(plus, 1);
plus1(2); // 3curry : Function -> Int -> Function
f : Function
arity : Integer (optional)
return : Function
Curry f. The returned function will wait until arity arguments have been passed before calling f. If arity is not specified it defaults to the number of arguments that f takes.
function plus(x, y) {
return x + y;
}
var plus = tlc.curry(plus);
var plus1 = plus(1);
plus1(2); // 3flip : (a -> b -> c) -> b -> a -> c
f : Function
return : Function
Reverses the order of f's arguments.
apply : (a -> ... -> z) -> (a, ..., y) -> z
f : Function
args : Array
return : Any
Calls f with args as its arguments and returns whatever f returns.
compose : (y -> z) -> ... -> (a -> b) -> a -> z
...fs : Functions
return : Function
Composes ...fs. tlc.compose(f1, f2, f3)(x) is equivalent to f1(f2(f3(x))).
memoize : Function -> Function
f : Function
return : Function
Returns a new function that behaves exactly like f except that its arguments are cached. So if the memoized function is called repeatedly with the same arguments f will only be called the first time. Every time after that, the cached value will be returned.
Argument equality is determined by the hashing function which is JSON.stringify.
memoizeBy : (a -> String) -> Function -> Function
hasher : hash Function
f : Function
return : Function
Like tlc.memoize but lets you specify a custom hashing function instead of JSON.stringify.