-
Notifications
You must be signed in to change notification settings - Fork 0
API Array
xs : Array-like
return : Array
Convert an array-like object to a native JavaScript array.
cloneArray : [a] -> [a]
xs : Array
return : Array
Make a copy of xs.
append : [a] -> [a] -> [a]
xs : Array
ys : Array
return : Array
Returns an array containing all the elements of xs and then all the elements of ys.
reverse : [a] -> [a]
xs : Array
return : Array
Reverses xs.
reduce : (b -> a -> b) -> b -> [a] -> b
f : Function
initVal : Any
xs : Array
return : Any
Reduce xs from left to right using the function f and the starting value of initVal. tlc.reduce(f, z, [x1, x2, x3]) is equivalent to f(f(f(z, x1), x2), x3).
reduceRight : (a -> b -> b) -> b -> [a] -> b
f : Function
initVal : Any
xs : Array
return : Any
Like tlc.reduce but goes from right to left. tlc.reduceRight(f, z, [x1, x2, x3]) is equivalent to f(x1, f(x2, f(x3, z))).
filter : (a -> Boolean) -> [a] -> [a]
p : Function
xs : Array
return : Array
Returns an Array of all xs for which p returns true.
find : (a -> Boolean) -> [a] -> Maybe a
p : Function
xs : Array
return : Maybe Any
Returns [Just](API Maybe) the first element of xs for which p returns true. Otherwise returns [Nothing](API Maybe).
findIndex : (a -> Boolean) -> [a] -> Maybe Int
p : Function
xs : Array
return : Maybe Int
Returns [Just](API Maybe) the index of the first element of xs for which p returns true. Otherwise returns [Nothing](API Maybe).
group : [a] -> [[a]]
xs : Array
return : 2-dimensional Array
Group consecutive and equal elements of xs into sub-arrays.
tlc.group([1, 1, 2, 3, 3, 3]); // [[1, 1], [2], [3, 3, 3]]groupBy : (a -> a -> Boolean) -> [a] -> [[a]]
eq : boolean Function
xs : Array
return : 2-dimensional Array
Like group but lets you specify an equality function.
minimum : [a] -> a
xs : Array
return : Number
xs is not empty.
Returns the minimum element of xs.
maximum : [a] -> a
xs : Array
return : Number
xs is not empty.
Returns the minimum element of xs.
sum : [Number] -> Number
xs : Array
return : Number
Returns the sum of all the elements of xs.
product : [Number] -> Number
xs : Array
return : Number
Returns the product of all the elements of xs.
length : [a] -> Int
xs : Array
return : Int
Returns the length of xs.
transpose : [[a]] -> [[a]]
xss : 2-dimensional Array
return : 2-dimensional Array
Returns xss with the rows and columns swapped.
tlc.transpose([[1, 2, 3], [4, 5, 6]]); // [[1, 4], [2, 5], [3, 6]]zip : [a] -> [b] -> [(a, b)]
xs : Array
ys : Array
return : 2-dimensional Array
Returns a 2-dimensional array where the ith array contains the ith element of xs and ys. This is a special case of tlc.transpose.
tlc.zip([1, 2, 3], [4, 5, 6]); // [[1, 4], [2, 5], [3, 6]]zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
f : Function
xs : Array
ys : Array
return : Array
Like tlc.zip except that you can specify a custom function f to combine the elements.
tlc.zipWith(tlc.op['+'], [1, 2, 3], [4, 5, 6]); // [5, 7, 9]sort : [a] -> [a]
xs : Array
return : Array
Sorts xs.
sortBy : (a -> a -> Int) -> [a] -> [a]
compare : comparison Function
xs : Array
return : Array
Like tlc.sort except allows you to specify a custom comparison function.
concat : [[a]] -> [a]
xss : 2-dimensional Array
return : Array
Flattens a 2-dimensional array into a 1-dimensional array.
tlc.concat([[1, 2], [3, 4]]); // [1, 2, 3, 4]and : [Boolean] -> Boolean
xs : Array of Booleans
return : Boolean
Returns true if all booleans in xs are true. Otherwise returns false.
or : [Boolean] -> Boolean
xs : Array of Booleans
return : Boolean
Returns true if there is at least one boolean in xs which is true. Otherwise returns false.
some : (a -> Boolean) -> [a] -> Boolean
p : Function
xs : Array
return : Boolean
Returns true if there is at least one element in xs for which p returns true. Otherwise returns false.
every : (a -> Boolean) -> [a] -> Boolean
p : Function
xs : Array
return : Boolean
Returns true if p returns true for every element in xs. Otherwise returns false.
contains : a -> [a] -> Boolean
item : Any
xs : Array
return : Boolean
Returns true if xs contains item. Otherwise returns false.
range : Int -> Int -> Int -> [Int]
start : Integer
stop : Integer
step : Integer (optional)
return : Array
Returns an array of integers starting at start and increasing by step until stop is reached. The step argument defaults to 1.
intersperse : a -> [a] -> [a]
sep : Any
xs : Array
return : Array
Returns an array with sep in between each of the elements of xs.
tlc.intersperse(0, [1, 2, 3]); // [1, 0, 2, 0, 3]