Skip to content
Jonathan Potter edited this page Jun 5, 2014 · 8 revisions

partial(f, ...args)

partial : Function -> ...a -> Function

Types

f : Function
...args : Anys
return : Function

Description

Returns f partially applied to ...args.

Example
function plus(x, y) {
    return x + y;
}

var plus1 = tlc.partial(plus, 1);
plus1(2); // 3

curry(f, [arity])

curry : Function -> Int -> Function

Types

f : Function
arity : Integer (optional)
return : Function

Description

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.

Example
function plus(x, y) {
    return x + y;
}

var plus = tlc.curry(plus);
var plus1 = plus(1);
plus1(2); // 3

flip(f)

flip : (a -> b -> c) -> b -> a -> c

Types

f : Function
return : Function

Description

Reverses the order of f's arguments.

apply(f, args)

apply : (a -> ... -> z) -> (a, ..., y) -> z

Types

f : Function
args : Array
return : Any

Description

Calls f with args as its arguments and returns whatever f returns.

compose(...fs)

compose : (y -> z) -> ... -> (a -> b) -> a -> z

Types

...fs : Functions
return : Function

Description

Composes ...fs. tlc.compose(f1, f2, f3)(x) is equivalent to f1(f2(f3(x))).

memoize(f)

memoize : Function -> Function

Types

f : Function
return : Function

Description

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(hasher, f)

memoizeBy : (a -> String) -> Function -> Function

Types

hasher : hash Function
f : Function
return : Function

Description

Like tlc.memoize but lets you specify a custom hashing function instead of JSON.stringify.

API

  • [Array](API Array)
  • [Function](API Function)
  • [Maybe](API Maybe)
  • [Object](API Object)
  • [Set](API Set)
  • [Typeclass](API Typeclass)

Guides

  • [Operators](Guide Operators)
  • [Typeclasses](Guide Typeclasses)
  • [Replacing OOP](Guide Replacing Object Oriented Programming)

General

Clone this wiki locally