A practical functional library for Javascript programmers.
Methods
-
add :: Number | String -> Number | String -> Number | String
-
Adds two numbers (or strings). Equivalent to
a + b
but curried.Name Type Description a
number | string The first value.
b
number | string The second value.
Returns:
result ofa + b
.
Example
var increment = add(1); increment(10); //= 11 add(2, 3); //= 5 add(7)(10); //= 17
-
allPredicates :: [(*... -> Boolean)] -> (*... -> Boolean)
-
Given a list of predicates returns a new predicate that will be true exactly when all of them are.
Name Type Description list
Array An array of predicate functions
optional
* Any arguments to pass into the predicates
Returns:
function that applies its arguments to each of the predicates, returningtrue
if all are satisfied.
Example
gt10 = function(x) { return x > 10; }; even = function(x) { return x % 2 === 0}; f = allPredicates([gt10, even]); f(11) // => false f(12) // => true
-
always :: a -> (* -> a)
-
Returns a function that always returns the given value.
Name Type Description val
* The value to wrap in a function
Returns:
Function :: * -> val
Example
var t = always('Tee'); t(); // => 'Tee'
-
alwaysFalse :: * -> false
-
A function that always returns
false
. Any passed in parameters are ignored.- See:
Example
alwaysFalse() // => false
-
alwaysTrue :: * -> true
-
A function that always returns
true
. Any passed in parameters are ignored.- See:
Example
alwaysTrue() // => true
-
alwaysZero :: * -> 0
-
A function that always returns
0
. Any passed in parameters are ignored.- See:
Returns:
zero.
Example
alwaysZero() // => 0
-
and :: (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
-
A function wrapping calls to the two functions in an
&&
operation, returningtrue
orfalse
. Note that this is short-circuited, meaning that the second function will not be invoked if the first returns a false-y value.Name Type Description f
function a predicate
g
function another predicate
Returns:
function that applies its arguments tof
andg
and ANDs their outputs together.
Example
gt10 = function(x) { return x > 10; }; even = function(x) { return x % 2 === 0 }; f = and(gt10, even); f(100) // => true f(101) // => false
-
anyPredicates :: [(*... -> Boolean)] -> (*... -> Boolean)
-
Given a list of predicates returns a new predicate that will be true exactly when any one of them is.
Name Type Description list
Array An array of predicate functions
optional
* Any arguments to pass into the predicates
Returns:
function that applies its arguments to each of the predicates, returningtrue
if all are satisfied..
Example
gt10 = function(x) { return x > 10; }; even = function(x) { return x % 2 === 0}; f = allPredicates([gt10, even]); f(11) // => true f(8) // => true f(9) // => false
-
ap :: [f] -> [a] -> [f a]
-
ap applies a list of functions to a list of values.
Name Type Description fns
Array An array of functions
vs
Array An array of values
Returns:
value of applying each the functionfns
to each value invs
Example
R.ap([R.multiply(2), R.add(3), [1,2,3]); //=> [2, 4, 6, 4, 5, 6]
-
append :: a -> [a] -> [a]
-
Returns a new list containing the contents of the given list, followed by the given element.
Name Type Description el
* The element to add to the end of the new list.
list
Array The list whose contents will be added to the beginning of the output list.
Returns:
new list containing the contents of the old list followed byel
.
Example
ramda.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] ramda.append('tests', []); //=> ['tests'] ramda.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
-
arity :: (Number, (* -> *)) -> (* -> *)
-
Wraps a function of any arity (including nullary) in a function that accepts exactly
n
parameters. UnlikenAry
, which passes onlyn
arguments to the wrapped function, functions produced byarity
will pass all provided arguments to the wrapped function.Name Type Description n
number The desired arity of the returned function.
fn
function The function to wrap.
Returns:
new function wrappingfn
. The new function is guaranteed to be of arityn
.
Example
var takesTwoArgs = function(a, b) { return [a, b]; }; takesTwoArgs.length; //=> 2 takesTwoArgs(1, 2); //=> [1, 2] var takesOneArg = ramda.unary(1, takesTwoArgs); takesOneArg.length; //=> 1 // All arguments are passed through to the wrapped function takesOneArg(1, 2); //=> [1, 2]
-
binary :: (* -> c) -> (a, b -> c)
-
Wraps a function of any arity (including nullary) in a function that accepts exactly 2 parameters. Any extraneous parameters will not be passed to the supplied function.
Name Type Description fn
function The function to wrap.
Returns:
new function wrappingfn
. The new function is guaranteed to be of arity 2.
Example
var takesThreeArgs = function(a, b, c) { return [a, b, c]; }; takesThreeArgs.length; //=> 3 takesThreeArgs(1, 2, 3); //=> [1, 2, 3] var takesTwoArgs = ramda.binary(1, takesThreeArgs); takesTwoArgs.length; //=> 2 // Only 2 arguments are passed to the wrapped function takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
-
- See:
-
- See:
-
chain :: (a -> b) -> [a] -> [c]
-
chain
maps a function over a list and concatenates the results. This implementation is compatible with the Fantasy-land Chain spec, and will work with types that implement that spec.chain
is also known asflatMap
in some librariesType Description function Array Example
var duplicate = function(n) { return [n, n]; }; R.chain(duplicate, [1, 2, 3]); // => [1, 1, 2, 2, 3, 3]
-
charAt :: Number -> String -> String
-
The character at the nth position in a String:
Name Type Description index
Number An integer between 0 and the length of the string.
str
String The string to extract a char from
- See:
Returns:
character atindex
ofstr
Example
charAt(8, 'abcdefghijklm'); //=> 'i'
-
charCodeAt :: Number -> String -> Number
-
The ascii code of the character at the nth position in a String:
Name Type Description index
Number An integer between 0 and the length of the string.
str
String The string to extract a charCode from
- See:
Returns:
code of the character atindex
ofstr
Example
charCodeAt(8, 'abcdefghijklm'); //=> 105 // (... 'a' ~ 97, 'b' ~ 98, ... 'i' ~ 105)
-
clone :: [a] -> [a]
-
Creates a shallow copy of an array.
Name Type Description list
Array The list to clone.
Returns:
new copy of the original list.
Example
var numbers = [1, 2, 3]; var numbersClone = ramda.clone(numbers); //=> [1, 2, 3] numbers === numbersClone; //=> false // Note that this is a shallow clone--it does not clone complex values: var objects = [{}, {}, {}]; var objectsClone = ramda.clone(objects); objects[0] === objectsClone[0]; //=> true
-
comparator :: (a, b -> Boolean) -> (a, b -> Number)
-
Makes a comparator function out of a function that reports whether the first element is less than the second.
Name Type Description pred
function A predicate function of arity two.
Returns:
Function :: a -> b -> Int that returns-1
if a < b,1
if b < a, otherwise0
Example
var cmp = comparator(function(a, b) { return a.age < b.age; }; sort(cmp, people);
-
compose :: ((y -> z), (x -> y), ..., (b -> c), (a... -> b)) -> (a... -> z)
-
Creates a new function that runs each of the functions supplied as parameters in turn, passing the return value of each function invocation to the next function invocation, beginning with whatever arguments were passed to the initial invocation.
Note that
compose
is a right-associative function, which means the functions provided will be invoked in order from right to left. In the examplevar h = compose(f, g)
, the functionh
is equivalent tof( g(x) )
, wherex
represents the arguments originally passed toh
.Name Type Description functions
function repeatable A variable number of functions.
Returns:
new function which represents the result of calling each of the inputfunctions
, passing the result of each function call to the next, from right to left.
Example
var triple = function(x) { return x * 3; }; var double = function(x) { return x * 2; }; var square = function(x) { return x * x; }; var squareThenDoubleThenTriple = ramda.compose(triple, double, square); squareThenDoubleThenTriple(5); //≅ triple(double(square(5))) => 150
-
concat :: [a] -> [a] -> [a]
-
Returns a new list consisting of the elements of the first list followed by the elements of the second.
Name Type Description list1
Array The first list to merge.
list2
Array The second set to merge.
Returns:
new array consisting of the contents oflist1
followed by the contents oflist2
. If, instead of an {Array} forlist1
, you pass an object with aconcat
method on it,concat
will calllist1.concat
and it the value oflist2
.
Example
ramda.concat([], []); //=> [] ramda.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] ramda.concat('ABC', 'DEF'); // 'ABCDEF'
-
- See:
-
construct :: (* -> {*}) -> (* -> {*})
-
Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
NOTE: Does not work with some built-in objects such as Date.
Name Type Description Fn
function The constructor function to wrap.
Returns:
wrapped, curried constructor function.
Example
// Constructor function var Widget = function(config) { // ... }; Widget.prototype = { // ... }; map(construct(Widget), allConfigs); //=> a list of Widgets
-
constructN :: Number -> (* -> {*}) -> (* -> {*})
-
Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. The arity of the function returned is specified to allow using variadic constructor functions.
NOTE: Does not work with some built-in objects such as Date.
Name Type Description n
number The arity of the constructor function.
Fn
function The constructor function to wrap.
Returns:
wrapped, curried constructor function.
Example
// Variadic constructor function var Widget = function() { this.children = Array.prototype.slice.call(arguments); // ... }; Widget.prototype = { // ... }; map(constructN(1, Widget), allConfigs); //=> a list of Widgets
-
contains :: a -> [a] -> Boolean
-
Returns
true
if the specified item is somewhere in the list,false
otherwise. Equivalent toindexOf(a)(list) > -1
. Uses strict (===
) equality checking.Name Type Description a
Object The item to compare against.
list
Array The array to consider.
Returns:
if the item is in the list,false
otherwise.
Example
contains(3)([1, 2, 3]); //= true contains(4)([1, 2, 3]); //= false contains({})([{}, {}]); //= false var obj = {}; contains(obj)([{}, obj, {}]); //= true
-
containsWith :: (x, a -> Boolean) -> x -> [a] -> Boolean
-
Returns
true
if thex
is found in thelist
, usingpred
as an equality predicate forx
.Name Type Description pred
function :: x -> x -> Bool
x
the item to find
list
Array the list to iterate over
Returns:
ifx
is inlist
, elsefalse
Example
var xs = [{x: 12}, {x: 11}, {x: 10}]; containsWith(function(a, b) { return a.x === b.x; }, {x: 10}, xs); // true containsWith(function(a, b) { return a.x === b.x; }, {x: 1}, xs); // false
-
countBy :: (a -> String) -> [a] -> {*}
-
Counts the elements of a list according to how many match each value of a key generated by the supplied function. Returns an object mapping the keys produced by
fn
to the number of occurrences in the list. Note that all keys are coerced to strings because of how JavaScript objects work.Name Type Description fn
function The function used to map values to keys.
list
Array The list to count elements from.
Returns:
object mapping keys to number of occurrences in the list.
Example
var numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; var letters = split('', 'abcABCaaaBBc'); countBy(Math.floor)(numbers); //= {'1': 3, '2': 2, '3': 1} countBy(toLowerCase)(letters); //= {'a': 5, 'b': 4, 'c': 3}
-
curry :: (* -> a) -> Number -> (* -> a) curry :: (* -> a) -> (* -> a)
-
Creates a new version of
fn
that, when invoked, will return either: - A new function ready to accept one or more offn
's remaining arguments, if all offn
's expected arguments have not yet been provided -fn
's result if all of its expected arguments have been providedOptionally, you may provide an arity for the returned function.
Name Type Default Description fn
function The function to curry.
fnArity
number fn.length optional An optional arity for the returned function.
Returns:
new, curried function.
Example
var addFourNumbers = function(a, b, c, d) { return a + b + c + d; }; var curriedAddFourNumbers = curry(addFourNumbers); var f = curriedAddFourNumbers(1, 2); var g = f(3); g(4);//=> 10
-
difference :: [a] -> [a] -> [a]
-
Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
Name Type Description list1
Array The first list.
list2
Array The second list.
- See:
Returns:
elements inlist1
that are not inlist2
Example
difference([1,2,3,4], [7,6,5,4,3]); //= [1,2] difference([7,6,5,4,3], [1,2,3,4]); //= [7,6,5]
-
differenceWith :: (a,a -> Boolean) -> [a] -> [a] -> [a]
-
Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
Name Type Description pred
function list1
Array The first list.
list2
Array The second list.
- See:
Returns:
first and second lists concatenated, with duplicates removed.
Example
function cmp(x, y) { return x.a === y.a; } var l1 = [{a: 1}, {a: 2}, {a: 3}]; var l2 = [{a: 3}, {a: 4}]; differenceWith(cmp, l1, l2); //= [{a: 1}, {a: 2}]
-
divide :: Number -> Number -> Number
-
Divides two numbers. Equivalent to
a / b
. While at times the curried version ofdivide
might be useful, probably the curried version ofdivideBy
will be more useful.Name Type Description a
number The first value.
b
number The second value.
- See:
Returns:
result ofa / b
.
Example
var reciprocal = divide(1); reciprocal(4); //= 0.25 divide(71, 100); //= 0.71
-
divideBy :: Number -> Number -> Number
-
Divides two numbers in reverse order. Equivalent to
b / a
.divideBy
is the reversed version ofdivide
, where the second parameter is divided by the first. The curried version ofdivideBy
may prove more useful than that ofdivide
.Name Type Description a
number The second value.
b
number The first value.
- See:
Returns:
result ofb / a
.
Example
var half = divideBy(2); half(42); // => 21
-
empty :: * -> []
-
empty
wraps any object in an array. This implementation is compatible with the Fantasy-land Monoid spec, and will work with types that implement that spec.Returns:
empty array
Example
R.empty([1,2,3,4,5]); // => []
-
eq :: a -> b -> Boolean
-
Tests if two items are equal. Equality is strict here, meaning reference equality for objects and non-coercing equality for primitives.
Name Type Description a
* b
* Example
var o = {}; eq(o, o) // => true eq(o, {}) // => false eq(1, 1) // => true eq(1, '1') // => false
-
eqProps :: k -> {k: v} -> {k: v} -> Boolean
-
Reports whether two functions have the same value for the specified property. Useful as a curried predicate.
Name Type Description prop
String The name of the property to compare
obj1
Object obj2
Object Example
o1 = {a: 1, b: 2, c: 3, d: 4}; o2 = { a: 10, b: 20, c: 3, d: 40}; eqProps('a', o1, o2) // => false eqProps('c', o1, o2) // => true
-
every :: (a -> Boolean) -> [a] -> Boolean
-
Returns
true
if all elements of the list match the predicate,false
if there are any that don't.Name Type Description fn
function The predicate function.
list
Array The array to consider.
Returns:
if the predicate is satisfied by every element,false
otherwise
Example
var lessThan2 = flip(lt)(2); var lessThan3 = flip(lt)(3); var xs = range(1, 3); //= [1, 2] every(lessThan2)(xs); //= false every(lessThan3)(xs); //= true
-
filter :: (a -> Boolean) -> [a] -> [a]
-
Returns a new list containing only those items that match a given predicate function. The predicate function is passed one argument: (value).
Note that
ramda.filter
does not skip deleted or unassigned indices, unlike the nativeArray.prototype.filter
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter#DescriptionName Type Description fn
function The function called per iteration.
list
Array The collection to iterate over.
Returns:
new filtered array.
Example
var isEven = function(n) { return n % 2 === 0; }; var evens = ramda.filter(isEven, [1, 2, 3, 4]); // => [2, 4]
-
filter.idx :: (a, i, [a] -> Boolean) -> [a] -> [a]
-
Like
filter
, but passes additional parameters to the predicate function. The predicate function is passed three arguments: (value, index, list).Name Type Description fn
function The function called per iteration.
list
Array The collection to iterate over.
Returns:
new filtered array.
Example
var lastTwo = function(val, idx, list) { return list.length - idx <= 2; }; ramda.filter.idx(lastTwo, [8, 6, 7, 5, 3, 0, 9]); //=> [0, 9]
-
find :: (a -> Boolean) -> [a] -> a | undefined
-
Returns the first element of the list which matches the predicate, or
undefined
if no element matches.Name Type Description fn
function The predicate function used to determine if the element is the desired one.
list
Array The array to consider.
Returns:
element found, orundefined
.
Example
var xs = [{a: 1}, {a: 2}, {a: 3}]; find(propEq('a', 2))(xs); //= {a: 2} find(propEq('a', 4))(xs); //= undefined
-
findIndex :: (a -> Boolean) -> [a] -> Number
-
Returns the index of the first element of the list which matches the predicate, or
-1
if no element matches.Name Type Description fn
function The predicate function used to determine if the element is the desired one.
list
Array The array to consider.
Returns:
index of the element found, or-1
.
Example
var xs = [{a: 1}, {a: 2}, {a: 3}]; findIndex(propEq('a', 2))(xs); //= 1 findIndex(propEq('a', 4))(xs); //= -1
-
findLast :: (a -> Boolean) -> [a] -> a | undefined
-
Returns the last element of the list which matches the predicate, or
undefined
if no element matches.Name Type Description fn
function The predicate function used to determine if the element is the desired one.
list
Array The array to consider.
Returns:
element found, orundefined
.
Example
var xs = [{a: 1, b: 0}, {a:1, b: 1}]; findLast(propEq('a', 1))(xs); //= {a: 1, b: 1} findLast(propEq('a', 4))(xs); //= undefined
-
findLastIndex :: (a -> Boolean) -> [a] -> Number
-
Returns the index of the last element of the list which matches the predicate, or
-1
if no element matches.Name Type Description fn
function The predicate function used to determine if the element is the desired one.
list
Array The array to consider.
Returns:
index of the element found, or-1
.
Example
var xs = [{a: 1, b: 0}, {a:1, b: 1}]; findLastIndex(propEq('a', 1))(xs); //= 1 findLastIndex(propEq('a', 4))(xs); //= -1
-
flatten :: [a] -> [b]
-
Returns a new list by pulling every item out of it (and all its sub-arrays) and putting them in a new array, depth-first.
Name Type Description list
Array The array to consider.
Returns:
flattened list.
Example
flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); //= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
-
flip :: (a -> b -> c -> ... -> z) -> (b -> a -> c -> ... -> z)
-
Returns a new function much like the supplied one, except that the first two arguments' order is reversed.
Name Type Description fn
function The function to invoke with its first two parameters reversed.
Returns:
result of invokingfn
with its first two parameters' order reversed.
Example
var mergeThree = function(a, b, c) { ([]).concat(a, b, c); }; var numbers = [1, 2, 3]; mergeThree(numbers); //=> [1, 2, 3] ramda.flip([1, 2, 3]); //=> [2, 1, 3]
-
- See:
-
- See:
-
- See:
-
- See:
-
forEach :: (a -> *) -> [a] -> [a]
-
Iterate over an input
list
, calling a provided functionfn
for each element in the list.fn
receives one argument: (value).Note:
ramda.forEach
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.forEach
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#DescriptionAlso note that, unlike
Array.prototype.forEach
, Ramda'sforEach
returns the original array. In some libraries this function is namedeach
.Name Type Description fn
function The function to invoke. Receives one argument,
value
.list
Array The list to iterate over.
Returns:
original list.
Example
ramda.forEach(function(num) { console.log(num + 100); }, [1, 2, 3]); //=> [1, 2, 3] //-> 101 //-> 102 //-> 103
-
forEach.idx :: (a, i, [a] -> ) -> [a] -> [a]
-
Like
forEach
, but but passes additional parameters to the predicate function.fn
receives three arguments: (value, index, list).Note:
ramda.forEach.idx
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.forEach
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#DescriptionAlso note that, unlike
Array.prototype.forEach
, Ramda'sforEach
returns the original array. In some libraries this function is namedeach
.Name Type Description fn
function The function to invoke. Receives three arguments: (
value
,index
,list
).list
Array The list to iterate over.
Returns:
original list.
Example
// Note that having access to the original `list` allows for // mutation. While you *can* do this, it's very un-functional behavior: ramda.forEach.idx(function(num, idx, list) { list[idx] = num + 100; }, [1, 2, 3]); //=> [101, 102, 103]
-
fork :: ((a, b -> c) -> (((* -> a), (* -> b), ...) -> c)
-
Accepts three functions and returns a new function. When invoked, this new function will invoke the first function,
after
, passing as its arguments the results of invoking the second and third functions with whatever arguments are passed to the new function.For example, a function produced by
fork
is equivalent to:var h = ramda.fork(e, f, g); h(1, 2); //≅ e( f(1, 2), g(1, 2) )
Name Type Description after
function A function.
after
will be invoked with the return values offn1
andfn2
as its arguments.fn1
function A function. It will be invoked with the arguments passed to the returned function. Afterward, its resulting value will be passed to
after
as its first argument.fn2
function A function. It will be invoked with the arguments passed to the returned function. Afterward, its resulting value will be passed to
after
as its second argument.Returns:
new function.
Example
var add = function(a, b) { return a + b; }; var multiply = function(a, b) { return a * b; }; var subtract = function(a, b) { return a - b; }; ramda.fork(multiply, add, subtract)(1, 2); //≅ multiply( add(1, 2), subtract(1, 2) ); //=> -3
-
fromPairs :: [[k,v]] -> {k: v}
-
Creates a new object out of a list key-value pairs.
Name Type Description An
Array array of two-element arrays that will be the keys and values of the ouput object.
Returns:
object made by pairing upkeys
andvalues
.
Example
fromPairs([['a', 1], ['b', 2], ['c', 3]]); //= {a: 1, b: 2, c: 3}
-
func :: (* -> *) -> {*} -> *
-
Calls the specified function on the supplied object. Any additional arguments after
fn
andobj
are passed in tofn
. If no additional arguments are passed tofunc
,fn
is invoked with no arguments.Name Type Description fn
String The name of the property mapped to the function to invoke
obj
Object The object
Returns:
value of invokingobj.fn
Example
func('add', R, 1, 2) // => 3 var obj = { f: function() { return 'f called'; } }; func('f', obj); // => 'f called'
-
functions :: {*} -> [String]
-
Returns a list of function names of object's own functions
Name Type Description obj
Object The objects with functions in it
Returns:
list of object's own function names
Example
R.functions(R) // => returns list of ramda's own function names var F = function() { this.x = function(){}; this.y = 1; } F.prototype.z = function() {}; F.prototype.a = 100; R.functions(new F()); // ["x"];
-
functionsIn :: {*} -> [String]
-
Returns a list of function names of object's own and prototype functions
Name Type Description obj
Object The objects with functions in it
Returns:
list of object's own and prototype function names
Example
R.functionsIn(R) // => returns list of ramda's own and prototype function names var F = function() { this.x = function(){}; this.y = 1; } F.prototype.z = function() {}; F.prototype.a = 100; R.functionsIn(new F()); // ["x", "z"];
-
- See:
-
groupBy :: (a -> s) -> [a] -> {s: a}
-
Splits a list into sublists stored in an object, based on the result of calling a String-returning function on each element, and grouping the results according to values returned.
Name Type Description fn
function Function :: a -> String
list
Array The array to group
Returns:
object with the output offn
for keys, mapped to arrays of elements that produced that key when passed tofn
.
Example
var byGrade = groupBy(function(student) { var score = student.score return (score < 65) ? 'F' : (score < 70) ? 'D' : (score < 80) ? 'C' : (score < 90) ? 'B' : 'A'; }; var students = [{name: 'Abby', score: 84}, {name: 'Eddy', score: 58}, // ... {name: 'Jack', score: 69}]; byGrade(students); //=> { // 'A': [{name: 'Dianne', score: 99}], // 'B': [{name: 'Abby', score: 84}] // // ..., // 'F': [{name: 'Eddy', score: 58}] // }
-
gt :: Number -> Number -> Boolean
-
Returns true if the first parameter is greater than the second.
Name Type Description a
Number b
Number Returns:
> b
Example
gt(2, 6) // => false gt(2, 0) // => true gt(2, 2) // => false
-
gte :: Number -> Number -> Boolean
-
Returns true if the first parameter is greater than or equal to the second.
Name Type Description a
Number b
Number Returns:
>= b
Example
gt(2, 6) // => false gt(2, 0) // => true gt(2, 2) // => true
-
head :: [a] -> a
-
Returns the first element in a list. In some libraries this function is named
first
.Name Type Default Description arr
Array [] optional The array to consider.
Returns:
first element of the list, orundefined
if the list is empty.
Example
ramda.head(['fi', 'fo', 'fum']); //=> 'fi'
-
- See:
-
identity :: a -> a
-
A function that does nothing but return the parameter supplied to it. Good as a default or placeholder function.
Name Type Description x
* The value to return.
Returns:
input value,x
.
Example
ramda.identity(1); //=> 1 var obj = {}; ramda.identity(obj) === obj; //=> true
-
indexOf :: a -> [a] -> Number
-
Returns the position of the first occurrence of an item in an array (by strict equality), or -1 if the item is not included in the array.
Name Type Description target
The item to find.
list
Array The array to search in.
Returns:
index of the target, or -1 if the target is not found.
Example
indexOf(3, [1,2,3,4]) // => 2 indexOf(10, [1,2,3,4]) // => -1
-
insert :: Number -> a -> [a] -> [a]
-
Inserts the supplied element into the list, at index
index
. Note that this is not destructive: it returns a copy of the list with the changes. No lists have been harmed in the application of this function.Name Type Description index
Number The position to insert the element
elt
The element to insert into the Array
list
Array The list to insert into
Returns:
new Array withelt
inserted atindex
Example
insert(2, 'x', [1,2,3,4]) // => [1,2,'x',3,4]
-
installTo :: -> {*} -> {*}
-
Expose the functions from ramda as properties of another object. If the provided object is the global object then the ramda functions become global functions. Warning: This function will mutate the object provided.
Name Type Description obj
Object The object to attach ramda functions
Returns:
reference to the mutated object
Example
var x = {} R.installTo(x) // => x now contains ramda functions R.installTo(this) // => add ramda functions to `this` object
-
intersection :: [a] -> [a] -> [a]
-
Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists.
Name Type Description list1
Array The first list.
list2
Array The second list.
- See:
Returns:
list of elements found in bothlist1
andlist2
Example
intersection(1,2,3,4], [7,6,5,4,3]); //= [1,2,3,4]
-
intersectionWith :: (a,a -> Boolean) -> [a] -> [a] -> [a]
-
Combines two lists into a set (i.e. no duplicates) composed of those elements common to both lists. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
Name Type Description pred
function A predicate function that determines whether the two supplied elements are equal. Signatrue: a -> a -> Boolean
list1
Array One list of items to compare
list2
Array A second list of items to compare
- See:
Returns:
new list containing those elements common to both lists.
Example
var buffaloSpringfield = [ {id: 824, name: 'Richie Furay'}, {id: 956, name: 'Dewey Martin'}, {id: 313, name: 'Bruce Palmer'}, {id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'} ]; var csny = [ {id: 204, name: 'David Crosby'}, {id: 456, name: 'Stephen Stills'}, {id: 539, name: 'Graham Nash'}, {id: 177, name: 'Neil Young'} ]; var sameId = function(o1, o2) {return o1.id === o2.id;}; intersectionWith(sameId, buffaloSpringfield, csny); //=> // [ // {id: 456, name: 'Stephen Stills'}, // {id: 177, name: 'Neil Young'} // ]
-
invoker :: (String, Object, Number) -> (* -> *)
-
Turns a named method of an object (or object prototype) into a function that can be called directly. Passing the optional
len
parameter restricts the returned function to the initiallen
parameters of the method.The returned function is curried and accepts
len + 1
parameters (ormethod.length + 1
whenlen
is not specified), and the final parameter is the target object.Name Type Description name
string The name of the method to wrap.
obj
Object The object to search for the
name
method.len
optional The desired arity of the wrapped method.
Returns:
new function orundefined
if the specified method is not found.
Example
var charAt = ramda.invoker('charAt', String.prototype); charAt(6, 'abcdefghijklm'); //=> 'g' var join = ramda.invoker('join', Array.prototype); var firstChar = charAt(0); join('', ramda.map(firstChar, ['light', 'ampliifed', 'stimulated', 'emission', 'radiation'])); //=> 'laser'
-
is :: (* -> {*}) -> a -> Boolean
-
See if an object (
val
) is an instance of the supplied constructor. This function will check up the inheritance chain, if any.Name Type Description ctor
Object A constructor
val
* The value to test
Example
is(Object, {}) // => true is(Number, 1) // => true is(String, 's') // => true is(String, new String('')) // => true is(Object, new String('')) // => true is(Number, {}) // => false
-
isAtom :: a -> Boolean
-
Returns
true
if the argument is an atom;false
otherwise. An atom is defined as any value that is not an array,undefined
, ornull
.Name Type Description x
* The element to consider.
Returns:
ifx
is an atom, andfalse
otherwise.
Example
ramda.isAtom([]); //=> false ramda.isAtom(null); //=> false ramda.isAtom(undefined); //=> false ramda.isAtom(0); //=> true ramda.isAtom(''); //=> true ramda.isAtom('test'); //=> true ramda.isAtom({}); //=> true
-
isEmpty :: [a] -> Boolean
-
Reports whether an array is empty.
Name Type Description arr
Array The array to consider.
Returns:
if thearr
argument has a length of 0 or ifarr
is a falsy value (e.g. undefined).
Example
ramda.isEmpty([1, 2, 3]); //=> false ramda.isEmpty([]); //=> true ramda.isEmpty(); //=> true ramda.isEmpty(null); //=> true
-
isSet :: [a] -> Boolean
-
Returns
true
if all elements are unique, otherwisefalse
. Uniquness is determined using strict equality (===
).Name Type Description list
Array The array to consider.
Returns:
if all elements are unique, elsefalse
.
Example
isSet(['1', 1]); //= true isSet([1, 1]); //= false isSet([{}, {}]); //= true
-
join :: String -> [a] -> String
-
Returns a string made by inserting the
separator
between each element and concatenating all the elements into a single string.Name Type Description separator
string | number The string used to separate the elements.
xs
Array The elements to join into a string.
Returns:
string made by concatenatingxs
withseparator
.
Example
var spacer = join(' '); spacer(['a', 2, 3.4]); //= 'a 2 3.4' join('|', [1, 2, 3]); //= '1|2|3'
-
keys :: {k: v} -> [k]
-
Returns a list containing the names of all the enumerable own properties of the supplied object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Name Type Description obj
Object The object to extract properties from
Returns:
array of the object's own properties
Example
keys({a: 1, b: 2, c: 3}) // => ['a', 'b', 'c']
-
keysIn :: {k: v} -> [k]
-
Returns a list containing the names of all the properties of the supplied object, including prototype properties. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Name Type Description obj
Object The object to extract properties from
Returns:
array of the object's own and prototype properties
Example
var F = function() { this.x = 'X'; }; F.prototype.y = 'Y'; var f = new F(); keys(f) // => ['x', 'y']
-
last :: [a] -> a
-
Returns the last element from a list.
Name Type Default Description arr
Array [] optional The array to consider.
Returns:
last element of the list, orundefined
if the list is empty.
Example
ramda.last(['fi', 'fo', 'fum']); //=> 'fum'
-
lastIndexOf :: a -> [a] -> Number
-
Returns the position of the last occurrence of an item (by strict equality) in an array, or -1 if the item is not included in the array.
Name Type Description target
The item to find.
list
Array The array to search in.
Returns:
index of the target, or -1 if the target is not found.
Example
lastIndexOf(3, [-1,3,3,0,1,2,3,4]) // => 6 lastIndexOf(10, [1,2,3,4]) // => -1
-
- See:
-
lPartial :: (a -> b -> ... -> i -> j -> ... -> m -> n) -> a -> b-> ... -> i -> (j -> ... -> m -> n)
-
Accepts as its arguments a function and any number of values and returns a function that, when invoked, calls the original function with all of the values prepended to the original function's arguments list. In some libraries this function is named
applyLeft
.Name Type Description fn
function The function to invoke.
args
* optional repeatable Arguments to prepend to
fn
when the returned function is invoked.Returns:
new function wrappingfn
. When invoked, it will callfn
withargs
prepended tofn
's arguments list.
Example
var multiply = function(a, b) { return a * b; }; var double = ramda.lPartial(multiply, 2); double(2); //=> 4 var greet = function(salutation, title, firstName, lastName) { return salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; }; var sayHello = ramda.lPartial(greet, 'Hello'); var sayHelloToMs = ramda.lPartial(sayHello, 'Ms.'); sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'
-
lt :: Number -> Number -> Boolean
-
Returns true if the first parameter is less than the second.
Name Type Description a
Number b
Number Returns:
< b
Example
lt(2, 6) // => true lt(2, 0) // => false lt(2, 2) // => false
-
lte :: Number -> Number -> Boolean
-
Returns true if the first parameter is less than or equal to the second.
Name Type Description a
Number b
Number Returns:
<= b
Example
lte(2, 6) // => true lt(2, 0) // => false lt(2, 2) // => true
-
map :: (a -> b) -> [a] -> [b]
-
Returns a new list, constructed by applying the supplied function to every element of the supplied list.
Note:
ramda.map
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.map
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#DescriptionName Type Description fn
function The function to be called on every element of the input
list
.list
Array The list to be iterated over.
Returns:
new list.
Example
var double = function(x) { return x * 2; }; ramda.map(double, [1, 2, 3]); //=> [2, 4, 6]
-
map.idx :: (a,i,[b] -> b) -> [a] -> [b]
-
Like
map
, but but passes additional parameters to the predicate function.fn
receives three arguments: (value, index, list).Note:
ramda.map.idx
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.map
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#DescriptionName Type Description fn
function The function to be called on every element of the input
list
.list
Array The list to be iterated over.
Returns:
new list.
Example
var squareEnds = function(elt, idx, list) { if (idx === 0 || idx === list.length - 1) { return elt * elt; } return elt; }; ramda.map.idx(squareEnds, [8, 6, 7, 5, 3, 0, 9]; //=> [64, 6, 7, 5, 3, 0, 81]
-
mapObj :: ({*}, String -> {*}) -> {*} -> {*}
-
Map, but for objects. Creates an object with the same keys as
obj
and values generated by running each property ofobj
throughfn
.fn
is passed one argument: (value).Name Type Description fn
Array A function called for each property in
obj
. Its return value will become a new property on the return object.obj
Object The object to iterate over.
Returns:
new object with the same keys asobj
and values that are the result of running each property throughfn
.
Example
var values = { x: 1, y: 2, z: 3 }; var double = function(num) { return num * 2; }; ramda.mapObj(double, values); //=> { x: 2, y: 4, z: 6 }
-
mapObj.idx :: ({*}, String, {*} -> {*}) -> {*} -> {*}
-
Like
mapObj
, but but passes additional arguments to the predicate function. The predicate function is passed three arguments: (value, key, obj).Name Type Description fn
Array A function called for each property in
obj
. Its return value willfn
Array A function called for each property in
obj
. Its return value will become a new property on the return object.obj
Object The object to iterate over.
Returns:
new object with the same keys asobj
and values that are the result of running each property throughfn
.
Example
var values = { x: 1, y: 2, z: 3 }; var double = function(num, key, obj) { return key + num; }; ramda.mapObj(double, values); //=> { x: 'x2', y: 'y4', z: 'z6' }
-
match :: RegExp -> String -> [String] | null
-
Tests a regular expression agains a String
Name Type Description rx
RegExp A regular expression.
str
String The string to match against
- See:
Returns:
list of matches, or null if no matches found
Example
match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
-
mathMod :: Number -> Number -> Number
-
mathMod behaves like the modulo operator should mathematically, unlike the
%
operator (and by extension, ramda.modulo). So while "-17 % 5" is -2, mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN when the modulus is zero or negative.Name Type Description m
number The dividend.
p
number the modulus.
- See:
Returns:
result ofb mod a
.
Example
mathMod(-17, 5) // 3 mathMod(17, 5) // 2 mathMod(17, -5) // NaN mathMod(17, 0) // NaN mathMod(17.2, 5) // NaN mathMod(17, 5.3) // NaN
-
max :: [Number] -> Number
-
Determines the largest of a list of numbers (or elements that can be cast to numbers)
Name Type Description list
Array A list of numbers
- See:
Returns:
greatest number in the list
Example
max([7, 3, 9, 2, 4, 9, 3]) // => 9
-
maxWith :: (a -> Number) -> [a] -> a
-
Determines the largest of a list of items as determined by pairwise comparisons from the supplied comparator
Name Type Description keyFn
function A comparator function for elements in the list
list
Array A list of comparable elements
- See:
Returns:
greatest element in the list.undefined
if the list is empty.
Example
function cmp(obj) { return obj.x; } a = {x: 1}, b = {x: 2}, c = {x: 3}; maxWith(cmp, [a, b, c]) // => {x: 3}
-
memoize :: (a... -> b) -> (a... -> b)
-
Creates a new function that, when invoked, caches the result of calling
fn
for a given argument set and returns the result. Subsequent calls to the memoizedfn
with the same argument set will not result in an additional call tofn
; instead, the cached result for that set of arguments will be returned.Note that this version of
memoize
effectively handles only string and number parameters.Name Type Description fn
function The function to be wrapped by
memoize
.Returns:
a memoized version offn
.
Example
var numberOfCalls = 0; var tracedAdd = function(a, b) { numberOfCalls += 1; return a + b; }; var memoTrackedAdd = ramda.memoize(trackedAdd); memoAdd(1, 2); //=> 3 (numberOfCalls => 1) memoAdd(1, 2); //=> 3 (numberOfCalls => 1) memoAdd(2, 3); //=> 5 (numberOfCalls => 2) // Note that argument order matters memoAdd(2, 1); //=> 3 (numberOfCalls => 3)
-
min :: [Number] -> Number
-
Determines the smallest of a list of numbers (or elements that can be cast to numbers)
Name Type Description list
Array A list of numbers
- See:
Returns:
greatest number in the list
Example
min([7, 3, 9, 2, 4, 9, 3]) // => 2
-
minWith :: (a -> Number) -> [a] -> a
-
Determines the smallest of a list of items as determined by pairwise comparisons from the supplied comparator
Name Type Description keyFn
function A comparator function for elements in the list
list
Array A list of comparable elements
- See:
Returns:
greatest element in the list.undefined
if the list is empty.
Example
function cmp(obj) { return obj.x; } var a = {x: 1}, b = {x: 2}, c = {x: 3}; minWith(cmp, [a, b, c]) // => {x: 1}
-
mixin :: {k: v} -> {k: v} -> {k: v}
-
Create a new object with the own properties of a merged with the own properties of object b. This function will not mutate passed-in objects.
Name Type Description a
Object source object
b
Object object with higher precendence in output
Returns:
the destination object.
Example
mixin({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); // => { 'name': 'fred', 'age': 40 }
-
modulo :: Number -> Number -> Number
-
Divides the second parameter by the first and returns the remainder. The flipped version (
moduloBy
) may be more useful curried. Note that this functions preserves the JavaScript-style behavior for modulo. For mathematical modulo seemathMod
Name Type Description a
number The value to the divide.
b
number The pseudo-modulus
- See:
Returns:
result ofb % a
.
Example
modulo(17, 3) // => 2 // JS behavior: modulo(-17, 3) // => -2 modulo(17, -3) // => 2
-
moduloBy :: Number -> Number -> Number
-
Reversed version of
modulo
, where the second parameter is divided by the first. The curried version of this one might be more useful than that ofmodulo
.Name Type Description m
number The dividend.
p
number the modulus.
- See:
Returns:
result ofb mod a
.
Example
var isOdd = moduloBy(2); isOdd(42); // => 0 isOdd(21); // => 1
-
multiply :: Number -> Number -> Number
-
Multiplies two numbers. Equivalent to
a * b
but curried.Name Type Description a
number The first value.
b
number The second value.
Returns:
result ofa * b
.
Example
var double = multiply(2); var triple = multiply(3); double(3); //= 6 triple(4); //= 12 multiply(2, 5); //= 10
-
nAry :: Number -> (* -> a) -> (* -> a)
-
Wraps a function of any arity (including nullary) in a function that accepts exactly
n
parameters. Any extraneous parameters will not be passed to the supplied function.Name Type Description n
number The desired arity of the new function.
fn
function The function to wrap.
Returns:
new function wrappingfn
. The new function is guaranteed to be of arityn
.
Example
var takesTwoArgs = function(a, b) { return [a, b]; }; takesTwoArgs.length; //=> 2 takesTwoArgs(1, 2); //=> [1, 2] var takesOneArg = ramda.nAry(1, takesTwoArgs); takesOneArg.length; //=> 1 // Only `n` arguments are passed to the wrapped function takesOneArg(1, 2); //=> [1, undefined]
-
not :: (*... -> Boolean) -> (*... -> Boolean)
-
A function wrapping a call to the given function in a
!
operation. It will returntrue
when the underlying function would return a false-y value, andfalse
when it would return a truth-y one.Name Type Description f
function a predicate
Returns:
function that applies its arguments tof
and logically inverts its output.
Example
gt10 = function(x) { return x > 10; }; f = not(gt10); f(11) // => false f(9) // => true
-
of :: a -> [a]
-
of
wraps any object in an Array. This implementation is compatible with the Fantasy-land Applicative spec, and will work with types that implement that spec. Note thisof
is different from the ES6of
; See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/ofName Type Description x
any value
Example
R.of(1); // => [1] R.of([2]); // => [[2]] R.of({}); // => [{}]
-
omit :: [k] -> {k: v} -> {k: v}
-
Returns a partial copy of an object omitting the keys specified.
Name Type Description names
Array an array of String propery names to omit from the new object
obj
Object The object to copy from
Returns:
new object with properties fromnames
not on it.
Example
omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) // => {b: 2, c: 3}
-
once :: (a... -> b) -> (a... -> b)
-
Accepts a function
fn
and returns a function that guards invocation offn
such thatfn
can only ever be called once, no matter how many times the returned function is invoked.Name Type Description fn
function The function to wrap in a call-only-once wrapper.
Returns:
wrapped function.
Example
var alertOnce = ramda.once(alert); alertOnce('Hello!'); // Alerts 'Hello!' alertOnce('Nothing'); // Doesn't alert alertOnce('Again'); // Doesn't alert
-
or :: (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
-
A function wrapping calls to the two functions in an
||
operation, returningtrue
orfalse
. Note that this is short-circuited, meaning that the second function will not be invoked if the first returns a truth-y value.Name Type Description f
function a predicate
g
function another predicate
Returns:
function that applies its arguments tof
andg
and ORs their outputs together.
Example
gt10 = function(x) { return x > 10; }; even = function(x) { return x % 2 === 0 }; f = or(gt10, even); f(101) // => false f(8) // => true
-
partition :: (a -> Boolean) -> [a] -> [[a],[a]]
-
Takes a predicate and a list and returns the pair of lists of elements which do and do not satisfy the predicate, respectively.
Name Type Description pred
function Function :: a -> Boolean
list
Array The array to partition
Returns:
nested array, containing first an array of elements that satisfied the predicate, and second an array of elements that did not satisfy.
Example
partition(contains('s'), ['sss', 'ttt', 'foo', 'bars']) // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
-
path :: String -> {*} -> *
-
Retrieve a nested path on an object seperated by periods
Name Type Description path
string The dot path to use.
Returns:
data atpath
.
Example
path('a.b', {a: {b: 2}}) //= 2
-
pathOn :: String -> String -> {*} -> *
-
Retrieve a nested path on an object seperated by the specified separator value.
Name Type Description sep
string The separator to use in
path
.path
string The path to use.
Returns:
data atpath
.
Example
pathOn('/', 'a/b/c', {a: {b: {c: 3}}}) //= 3
-
pick :: [k] -> {k: v} -> {k: v}
-
Returns a partial copy of an object containing only the keys specified. If the key does not exist, the property is ignored.
Name Type Description names
Array an array of String propery names to copy onto a new object
obj
Object The object to copy from
Returns:
new object with only properties fromnames
on it.
Example
pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) // => {a: 1, d: 4} pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}) // => {a: 1}
-
pickAll :: [k] -> {k: v} -> {k: v}
-
Similar to
pick
except that this one includes akey: undefined
pair for properties that don't exist.Name Type Description names
Array an array of String propery names to copy onto a new object
obj
Object The object to copy from
- See:
Returns:
new object with only properties fromnames
on it.
Example
pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}) // => {a: 1, d: 4} pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}) // => {a: 1, e: undefined, f: undefined}
-
pickWith :: (v, k -> Boolean) -> {k: v} -> {k: v}
-
Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.
Name Type Description pred
function A predicate to determine whether or not a key should be included on the output object.
obj
Object The object to copy from
- See:
Returns:
new object with only properties that satisfypred
on it.
Example
function isUpperCase(x) { return x.toUpperCase() === x; } pickWith(isUpperCase, {a: 1, b: 2, A: 3, B: 4}) // => {A: 3, B: 4}
-
pipe :: ((a... -> b), (b -> c), ..., (x -> y), (y -> z)) -> (a... -> z)
-
Creates a new function that runs each of the functions supplied as parameters in turn, passing the return value of each function invocation to the next function invocation, beginning with whatever arguments were passed to the initial invocation.
pipe
is the mirror version ofcompose
.pipe
is left-associative, which means that each of the functions provided is executed in order from left to right.In some libraries this function is named
sequence
.Name Type Description functions
function repeatable A variable number of functions.
Returns:
new function which represents the result of calling each of the inputfunctions
, passing the result of each function call to the next, from right to left.
Example
var triple = function(x) { return x * 3; }; var double = function(x) { return x * 2; }; var square = function(x) { return x * x; }; var squareThenDoubleThenTriple = ramda.pipe(square, double, triple); squareThenDoubleThenTriple(5); //≅ triple(double(square(5))) => 150
-
pluck :: String -> {*} -> [*]
-
Returns a new list by plucking the same named property off all objects in the list supplied.
Name Type Description key
string | number The key name to pluck off of each object.
list
Array The array to consider.
Returns:
list of values for the given key.
Example
pluck('a')([{a: 1}, {a: 2}]); //= [1, 2] pluck(0)([[1, 2], [3, 4]]); //= [1, 3]
-
prepend :: a -> [a] -> [a]
-
Returns a new list with the given element at the front, followed by the contents of the list.
Name Type Description el
* The item to add to the head of the output list.
arr
Array The array to add to the tail of the output list.
Returns:
new array.
Example
ramda.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
-
product :: [Number] -> Number
-
Multiplies together all the elements of a list.
Name Type Description list
Array An array of numbers
- See:
-
- reduce
Returns:
product of all the numbers in the list.
Example
product([2,4,6,8,100,1]); // => 38400
-
Reasonable analog to SQL
select
statement.Name Type Description props
Array The property names to project
objs
Array The objects to query
Returns:
array of objects with just theprops
properties.
Example
var abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}, var fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7} var kids = [abby, fred]; project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
-
prop :: s -> {s: a} -> a
-
Returns a function that when supplied an object returns the indicated property of that object, if it exists.
Name Type Description p
String The property name
obj
Object The object to query
Returns:
value at obj.p
Example
prop('x', {x: 100}) // => 100 prop('x', {}) // => undefined var fifth = prop(4); // indexed from 0, remember fifth(['Bashful', 'Doc', 'Dopey', 'Grumpy', 'Happy', 'Sleepy', 'Sneezy']); //=> 'Happy'
-
propEq :: k -> v -> {k: v} -> Boolean
-
Determines whether the given property of an object has a specific value according to strict equality (
===
). Most likely used to filter a list:Name Type Description name
string | number The property name (or index) to use.
val
* The value to compare the property with.
Returns:
if the properties are equal,false
otherwise.
Example
var abby = {name: 'Abby', age: 7, hair: 'blond'}; var fred = {name: 'Fred', age: 12, hair: 'brown'}; var rusty = {name: 'Rusty', age: 10, hair: 'brown'}; var alois = {name: 'Alois', age: 15, disposition: 'surly'}; var kids = [abby, fred, rusty, alois]; var hasBrownHair = propEq('hair', 'brown'); filter(hasBrownHair, kids); //= [fred, rusty]
-
propOrDefault :: s -> v -> {s: x} -> x | v
-
If the given object has an own property with the specified name, returns the value of that property. Otherwise returns the provided default value.
Name Type Description p
String The name of the property to return.
val
* The default value.
Returns:
value of given property or default value.
Example
var alice = { name: 'ALICE', age: 101 }; var favorite = prop('favoriteLibrary'); var favoriteWithDefault = propOrDefault('favoriteLibrary', 'Ramda'); favorite(alice); //=> undefined favoriteWithDefault(alice); //=> 'Ramda'
-
props :: {s: a} -> s -> a
-
Returns the value at the specified property. The only difference from
prop
is the parameter order.Name Type Description obj
Object The object to query
prop
String The property name
- See:
Returns:
value at obj.p
Example
prop({x: 100}, 'x'); // => 100
-
- See:
-
range :: Number -> Number -> [Number]
-
Returns a list of numbers from
from
(inclusive) toto
(exclusive). In mathematical terms,range(a, b)
is equivalent to the half-open interval[a, b)
.Name Type Description from
number The first number in the list.
to
number One more than the last number in the list.
Returns:
list of numbers in tthe set[a, b)
.
Example
range(1, 5); //= [1, 2, 3, 4] range(50, 53); //= [50, 51, 52]
-
reduce :: (a,b -> a) -> a -> [b] -> a
-
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
The iterator function receives two values: (acc, value)
Note:
ramda.reduce
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.reduce
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#DescriptionName Type Description fn
function The iterator function. Receives two values, the accumulator and the current element from the array.
acc
* The accumulator value.
list
Array The list to iterate over.
Returns:
final, accumulated value.
Example
var numbers = [1, 2, 3]; var add = function(a, b) { return a + b; }; reduce(numbers, add, 10); //=> 16
-
reduce.idx :: (a,b,i,[b] -> a) -> a -> [b] -> a
-
Like
reduce
, but passes additional parameters to the predicate function.The iterator function receives four values: (acc, value, index, list)
Note:
ramda.reduce.idx
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.reduce
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#DescriptionName Type Description fn
function The iterator function. Receives four values: the accumulator, the current element from
list
, that element's index, and the entirelist
itself.acc
* The accumulator value.
list
Array The list to iterate over.
Returns:
final, accumulated value.
Example
var letters = ['a', 'b', 'c']; var objectify = function(accObject, elem, idx, list) { return accObject[elem] = idx; }; reduce.idx(letters, objectify, {}); //=> { 'a': 0, 'b': 1, 'c': 2 }
-
reduceRight :: (a,b -> a) -> a -> [b] -> a
-
Returns a single item by iterating through the list, successively calling the iterator function and passing it an accumulator value and the current value from the array, and then passing the result to the next call.
Similar to
reduce
, except moves through the input list from the right to the left.The iterator function receives two values: (acc, value)
Note:
ramda.reduce
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.reduce
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#DescriptionName Type Description fn
function The iterator function. Receives two values, the accumulator and the current element from the array.
acc
* The accumulator value.
list
Array The list to iterate over.
Returns:
final, accumulated value.
Example
var pairs = [ ['a', 1], ['b', 2], ['c', 3] ]; var flattenPairs = function(acc, pair) { return acc.concat(pair); }; reduceRight(numbers, flattenPairs, []); //=> [ 'c', 3, 'b', 2, 'a', 1 ]
-
reduceRight.idx :: (a,b,i,[b] -> a -> [b] -> a
-
Like
reduceRight
, but passes additional parameters to the predicate function. Moves through the input list from the right to the left.The iterator function receives four values: (acc, value, index, list).
Note:
ramda.reduceRight.idx
does not skip deleted or unassigned indices (sparse arrays), unlike the nativeArray.prototype.reduce
method. For more details on this behavior, see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#DescriptionName Type Description fn
function The iterator function. Receives four values: the accumulator, the current element from
list
, that element's index, and the entirelist
itself.acc
* The accumulator value.
list
Array The list to iterate over.
Returns:
final, accumulated value.
Example
var letters = ['a', 'b', 'c']; var objectify = function(accObject, elem, idx, list) { return accObject[elem] = idx; }; reduceRight.idx(letters, objectify, {}); //=> { 'c': 2, 'b': 1, 'a': 0 }
-
reject :: (a -> Boolean) -> [a] -> [a]
-
Similar to
filter
, except that it keeps only values for which the given predicate function returns falsy. The predicate function is passed one argument: (value).Name Type Description fn
function The function called per iteration.
list
Array The collection to iterate over.
Returns:
new filtered array.
Example
var isOdd = function(n) { return n % 2 === 1; }; var evens = ramda.reject(isOdd, [1, 2, 3, 4]); // => [2, 4]
-
reject.idx :: (a, i, [a] -> Boolean) -> [a] -> [a]
-
Like
reject
, but passes additional parameters to the predicate function. The predicate function is passed three arguments: (value, index, list).Name Type Description fn
function The function called per iteration.
list
Array The collection to iterate over.
Returns:
new filtered array.
Example
var lastTwo = function(val, idx, list) { return list.length - idx <= 2; }; reject.idx(lastTwo, [8, 6, 7, 5, 3, 0, 9]); //=> [8, 6, 7, 5, 3]
-
remove :: Number -> Number -> [a] -> [a]
-
Removes the sub-list of
list
starting at indexstart
and containingcount
elements. Note that this is not destructive: it returns a copy of the list with the changes. No lists have been harmed in the application of this function.Name Type Description start
Number The position to start removing elements
count
Number The number of elements to remove
list
Array The list to remove from
Returns:
new Array withcount
elements fromstart
removed
Example
remove(2, 3, [1,2,3,4,5,6,7,8]) // => [1,2,6,7,8]
-
repeatN :: a -> n -> [a]
-
Returns a fixed list of size
n
containing a specified identical value.Name Type Description value
* The value to repeat.
n
number The desired size of the output list.
Returns:
new array containingn
value
s.
Example
ramda.repeatN('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] var obj = {}; var repeatedObjs = ramda.repeatN(obj, 5); //=> [{}, {}, {}, {}, {}] repeatedObjs[0] === repeatedObjs[1]; //=> true
-
reverse :: [a] -> [a]
-
Returns a new list with the same elements as the original list, just in the reverse order.
Name Type Description list
Array The list to reverse.
Returns:
copy of the list in reverse order.
Example
reverse([1, 2, 3]); //= [3, 2, 1] reverse([1, 2]); //= [2, 1] reverse([1]); //= [1] reverse([]); //= []
-
rPartial :: (a -> b-> ... -> i -> j -> ... -> m -> n) -> j -> ... -> m -> n -> (a -> b-> ... -> i)
-
Accepts as its arguments a function and any number of values and returns a function that, when invoked, calls the original function with all of the values appended to the original function's arguments list.
Note that
rPartial
is the opposite oflPartial
:rPartial
fillsfn
's arguments from the right to the left. In some libraries this function is namedapplyRight
.Name Type Description fn
function The function to invoke.
args
* optional repeatable Arguments to append to
fn
when the returned function is invoked.Returns:
new function wrappingfn
. When invoked, it will callfn
withargs
appended tofn
's arguments list.
Example
var greet = function(salutation, title, firstName, lastName) { return salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; }; var greetMsJaneJones = ramda.rPartial(greet, 'Ms.', 'Jane', 'Jones'); greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'
-
size :: [a] -> Number
-
Returns the number of elements in the array by returning
arr.length
.Name Type Description arr
Array The array to inspect.
Returns:
size of the array.
Example
ramda.size([]); //=> 0 ramda.size([1, 2, 3]); //=> 3
-
skip :: Number -> [a] -> [a]
-
Returns a new list containing all but the first
n
elements of the givenlist
.Name Type Description n
number The number of elements of
list
to skip.list
Array The array to consider.
Returns:
lastn
elements oflist
.
Example
skip(3, [1,2,3,4,5,6,7]); // => [4,5,6,7]
-
skipUntil :: (a -> Boolean) -> [a] -> [a]
-
Returns a new list containing the last
n
elements of a given list, passing each value to the supplied predicate function, beginning when the predicate function returnstrue
. Excludes the element that caused the predicate function to fail. The predicate function is passed one argument: (value).Name Type Description fn
function The function called per iteration.
list
Array The collection to iterate over.
Returns:
new array.
Example
var isNotTwo = function(x) { return !(x === 2); }; skipUntil(isNotFour, [1, 2, 3, 4]); //=> [1, 2, 3]
-
slice :: Number -> Number -> [a] -> [a]
-
Returns the elements from
xs
starting ata
and ending atb - 1
.Name Type Description a
number The starting index.
b
number One more than the ending index.
xs
Array The list to take elements from.
Returns:
items froma
tob - 1
fromxs
.
Example
var xs = range(0, 10); slice(2, 5)(xs); //= [2, 3, 4]
-
some :: (a -> Boolean) -> [a] -> Boolean
-
Returns
true
if at least one of elements of the list match the predicate,false
otherwise.Name Type Description fn
function The predicate function.
list
Array The array to consider.
Returns:
if the predicate is satisfied by at least one element,false
otherwise
Example
var lessThan0 = flip(lt)(0); var lessThan2 = flip(lt)(2); var xs = range(1, 3); //= [1, 2] some(lessThan0)(xs); //= false some(lessThan2)(xs); //= true
-
sort :: (a,a -> Number) -> [a] -> [a]
-
Returns a copy of the list, sorted according to the comparator function, which should accept two values at a time and return a negative number if the first value is smaller, a positive number if it's larger, and zero if they are equal. Please note that this is a copy of the list. It does not modify the original.
Name Type Description comparator
function A sorting function :: a -> b -> Int
list
Array The list to sort
Returns:
new array with its elements sorted by the comparator function.
Example
sort(function(a, b) { return a - b; }, [4,2,7,5]); // => [2, 4, 5, 7];
-
sortBy :: (a -> String) -> [a] -> [a]
-
Sorts the list according to a key generated by the supplied function.
Name Type Description fn
function The function mapping
list
items to keys.list
Array The list to sort.
Returns:
new list sorted by the keys generated byfn
.
Example
var sortByFirstItem = sortBy(prop(0)); var sortByNameCaseInsensitive = sortBy(compose(toLowerCase, prop('name'))); var pairs = [[-1, 1], [-2, 2], [-3, 3]]; sortByFirstItem(pairs); //= [[-3, 3], [-2, 2], [-1, 1]] var alice = { name: 'ALICE', age: 101 }; var bob = { name: 'Bob', age: -10 }; var clara = { name: 'clara', age: 314.159 }; var people = [clara, bob, alice]; sortByNameCaseInsensitive(people); //= [alice, bob, clara]
-
split :: String -> String -> [String]
-
Splits a string into an array of strings based on the given separator.
Name Type Description sep
string The separator string.
str
string The string to separate into an array.
Returns:
array of strings fromstr
separated bystr
.
Example
var pathComponents = split('/'); pathComponents('/usr/local/bin/node'); //= ['usr', 'local', 'bin', 'node'] split('.', 'a.b.c.xyz.d'); //= ['a', 'b', 'c', 'xyz', 'd']
-
strIndexOf :: String -> String -> Number
-
Finds the first index of a substring in a string, returning -1 if it's not present
Name Type Description c
String A string to find.
str
String The string to search in
- See:
Returns:
first index ofc
or -1 if not found
Example
strIndexOf('c', 'abcdefg) //=> 2
-
strLastIndexOf :: String -> String -> Number
-
Finds the last index of a substring in a string, returning -1 if it's not present
Name Type Description c
String A string to find.
str
String The string to search in
- See:
Returns:
last index ofc
or -1 if not found
Example
strLastIndexOf('a', 'banana split') //=> 5
-
substring :: Number -> Number -> String -> String
-
returns a subset of a string between one index and another.
Name Type Description indexA
Number An integer between 0 and the length of the string.
indexB
Number An integer between 0 and the length of the string.
The
String string to extract from
- See:
Returns:
extracted substring
Example
substring(2, 5, 'abcdefghijklm'); //=> 'cde'
-
substringFrom :: Number -> String -> String
-
The trailing substring of a String starting with the nth character:
Name Type Description indexA
Number An integer between 0 and the length of the string.
The
String string to extract from
- See:
Returns:
extracted substring
Example
substringFrom(8, 'abcdefghijklm'); //=> 'ijklm'
-
substringTo :: Number -> String -> String
-
The leading substring of a String ending before the nth character:
Name Type Description indexA
Number An integer between 0 and the length of the string.
The
String string to extract from
- See:
Returns:
extracted substring
Example
substringTo(8, 'abcdefghijklm'); //=> 'abcdefgh'
-
subtract :: Number -> Number -> Number
-
Subtracts two numbers. Equivalent to
a - b
but curried.Name Type Description a
number The first value.
b
number The second value.
- See:
Returns:
result ofa - b
.
Example
var complementaryAngle = subtract(90); complementaryAngle(30); //= 60 var theRestOf = subtract(1); theRestOf(0.25); //= 0.75 subtract(10)(8); //= 2
-
subtractN :: Number -> Number -> Number
-
Subtracts two numbers in reverse order. Equivalent to
b - a
but curried. Probably more useful when partially applied thansubtract
.Name Type Description a
number The first value.
b
number The second value.
Returns:
result ofa - b
.
Example
var complementaryAngle = subtract(90); complementaryAngle(30); //= 60 var theRestOf = subtract(1); theRestOf(0.25); //= 0.75 subtract(10)(8); //= 2
-
sum :: [Number] -> Number
-
Adds together all the elements of a list.
Name Type Description list
Array An array of numbers
- See:
-
- reduce
Returns:
sum of all the numbers in the list.
Example
sum([2,4,6,8,100,1]); // => 121
-
tail :: [a] -> [a]
-
Returns all but the first element of a list. If the list provided has the
tail
method, it will instead returnlist.tail()
.Name Type Default Description arr
Array [] optional The array to consider.
Returns:
new array containing all but the first element of the input list, or an empty list if the input list is a falsy value (e.g.undefined
).
Example
ramda.tail(['fi', 'fo', 'fum']); //=> ['fo', 'fum']
-
take :: Number -> [a] -> [a]
-
Returns a new list containing the first
n
elements of the given list. Ifn > * list.length
, returns a list oflist.length
elements.Name Type Description n
number The number of elements to return.
list
Array The array to query.
Returns:
new array containing the first elements oflist
.
-
takeWhile :: (a -> Boolean) -> [a] -> [a]
-
Returns a new list containing the first
n
elements of a given list, passing each value to the supplied predicate function, and terminating when the predicate function returnsfalse
. Excludes the element that caused the predicate function to fail. The predicate function is passed one argument: (value).Name Type Description fn
function The function called per iteration.
list
Array The collection to iterate over.
Returns:
new array.
Example
var isNotFour = function(x) { return !(x === 4); }; takeWhile(isNotFour, [1, 2, 3, 4]); //=> [1, 2, 3]
-
tap :: a -> (a -> *) -> a
-
Runs the given function with the supplied object, then returns the object.
Name Type Description x
* fn
function The function to call with
x
. The return value offn
will be thrown away.Example
tap(100, function(x) { console.log('x is ' + x); }); // => 100 (and logs: 'x is 100')
-
times :: (i -> a) -> i -> [a]
-
Calls an input function
n
times, returning an array containing the results of those function calls.fn
is passed one argument: The current value ofn
, which begins at0
and is gradually incremented ton - 1
.Name Type Description fn
function The function to invoke. Passed one argument, the current value of
n
.n
number A value between
0
andn - 1
. Increments after each function call.Returns:
array containing the return values of all calls tofn
.
Example
ramda.times(function(n) { return n; }, 5); //=> [0, 1, 2, 3, 4]
-
toLowerCase :: String -> String
-
The lower case version of a string.
Name Type Description str
string The string to lower case.
Returns:
lower case version ofstr
.
Example
toLowerCase('XYZ') //= 'xyz'
-
toPairs :: {k: v} -> [[k,v]]
-
Converts an object into an array of key, value arrays. Only the object's own properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Name Type Description obj
Object The object to extract from
Returns:
array of key, value arrays from the object's own properties
Example
toPairs({a: 1, b: 2, c: 3}); // [['a', 1], ['b', 2], ['c', 3]]
-
toPairsIn :: {k: v} -> [[k,v]]
-
Converts an object into an array of key, value arrays. The object's own properties and prototype properties are used. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Name Type Description obj
Object The object to extract from
Returns:
array of key, value arrays from the object's own and prototype properties
Example
var F = function() { this.x = 'X'; }; F.prototype.y = 'Y'; var f = new F(); toPairsIn(f) // => [['x','X'], ['y','Y']]
-
toUpperCase :: String -> String
-
The upper case version of a string.
Name Type Description str
string The string to upper case.
Returns:
upper case version ofstr
.
Example
toUpperCase('abc') //= 'ABC'
-
unary :: (* -> b) -> (a -> b)
-
Wraps a function of any arity (including nullary) in a function that accepts exactly 1 parameter. Any extraneous parameters will not be passed to the supplied function.
Name Type Description fn
function The function to wrap.
Returns:
new function wrappingfn
. The new function is guaranteed to be of arity 1.
Example
var takesTwoArgs = function(a, b) { return [a, b]; }; takesTwoArgs.length; //=> 2 takesTwoArgs(1, 2); //=> [1, 2] var takesOneArg = ramda.unary(1, takesTwoArgs); takesOneArg.length; //=> 1 // Only 1 argument is passed to the wrapped function takesOneArg(1, 2); //=> [1, undefined]
-
unfoldr :: (a -> [b]) -> * -> [b]
-
Builds a list from a seed value. Accepts an iterator function, which returns either false to stop iteration or an array of length 2 containing the value to add to the resulting list and the seed to be used in the next call to the iterator function.
The iterator function receives one argument: (seed).
Name Type Description fn
function The iterator function. receives one argument,
seed
, and returns either false to quit iteration or an array of length two to proceed. The element at index 0 of this array will be added to the resulting array, and the element at index 1 will be passed to the next call tofn
.seed
* The seed value.
Returns:
final list.
Example
var f = function(n) { return n > 50 ? false : [-n, n + 10] }; unfoldr(f, 10) //= [-10, -20, -30, -40, -50]
-
union :: [a] -> [a] -> [a]
-
Combines two lists into a set (i.e. no duplicates) composed of the elements of each list.
Name Type Description as
Array The first list.
bs
Array The second list.
Returns:
first and second lists concatenated, with duplicates removed.
Example
union([1, 2, 3], [2, 3, 4]); //= [1, 2, 3, 4]
-
unionWith :: (a,a -> Boolean) -> [a] -> [a] -> [a]
-
Combines two lists into a set (i.e. no duplicates) composed of the elements of each list. Duplication is determined according to the value returned by applying the supplied predicate to two list elements.
Name Type Description pred
function list1
Array The first list.
list2
Array The second list.
- See:
Returns:
first and second lists concatenated, with duplicates removed.
Example
function cmp(x, y) { return x.a === y.a; } var l1 = [{a: 1}, {a: 2}]; var l2 = [{a: 1}, {a: 4}]; unionWith(cmp, l1, l2); //= [{a: 1}, {a: 2}, {a: 4}]
-
uniq :: [a] -> [a]
-
Returns a new list containing only one copy of each element in the original list. Equality is strict here, meaning reference equality for objects and non-coercing equality for primitives.
Name Type Description list
Array The array to consider.
Returns:
list of unique items.
Example
uniq([1, 1, 2, 1]); //= [1, 2] uniq([{}, {}]); //= [{}, {}] uniq([1, '1']); //= [1, '1']
-
uniqWith :: (x, a -> Boolean) -> [a] -> [a]
-
Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied predicate to two list elements. Prefers the first item if two items compare equal based on the predicate.
Name Type Description list
Array The array to consider.
Returns:
list of unique items.
Example
var strEq = function(a, b) { return ('' + a) === ('' + b) }; uniqWith(strEq)([1, '1', 2, 1]); //= [1, 2] uniqWith(strEq)([{}, {}]); //= [{}] uniqWith(strEq)([1, '1', 1]); //= [1] uniqWith(strEq)(['1', 1, 1]); //= ['1']
-
unnest :: [a] -> [b]
-
Returns a new list by pulling every item at the first level of nesting out, and putting them in a new array.
Name Type Description list
Array The array to consider.
Returns:
flattened list.
Example
unnest([1, [2], [[3]]]); //= [1, 2, [3]] unnest([[1, 2], [3, 4], [5, 6]]); //= [1, 2, 3, 4, 5, 6]
-
useWith :: ((* -> *), (* -> *)...) -> (* -> *)
-
Accepts a function
fn
and any number of transformer functions and returns a new function. When the new function is invoked, it calls the functionfn
with parameters consisting of the result of calling each supplied handler on successive arguments to the new function. For example:var useWithExample = R.useWith(someFn, transformerFn1, transformerFn2); // This invocation: useWithExample('x', 'y'); // Is functionally equivalent to: someFn(transformerFn1('x'), transformerFn2('y'))
If more arguments are passed to the returned function than transformer functions, those arguments are passed directly to
fn
as additional parameters. If you expect additional arguments that don't need to be transformed, although you can ignore them, it's best to pass an identity function so that the new function reports the correct arity.Name Type Description fn
function The function to wrap.
transformers
function repeatable A variable number of transformer functions
Returns:
wrapped function.
Example
var double = function(y) { return y * 2; }; var square = function(x) { return x * x; }; var add = function(a, b) { return a + b; }; // Adds any number of arguments together var addAll = function() { return ramda.reduce(add, 0, arguments); }; // Basic example var addDoubleAndSquare = ramda.useWith(addAll, double, square); addDoubleAndSquare(10, 5); //≅ addAll(double(10), square(5)); //=> 125 // Example of passing more arguments than transformers addDoubleAndSquare(10, 5, 100); //≅ addAll(double(10), square(5), 100); //=> 225 // But if you're expecting additional arguments that don't need transformation, it's best // to pass transformer functions so the resulting function has the correct arity var addDoubleAndSquareWithExtraParams = ramda.useWith(addAll, double, square, ramda.identity); addDoubleAndSquare(10, 5, 100); //≅ addAll(double(10), square(5), ramda.identity(100)); //=> 225
-
values :: {k: v} -> [v]
-
Returns a list of all the enumerable own properties of the supplied object. Note that the order of the output array is not guaranteed across different JS platforms.
Name Type Description obj
Object The object to extract values from
Returns:
array of the values of the object's own properties
Example
values({a: 1, b: 2, c: 3}) // => [1, 2, 3]
-
valuesIn :: {k: v} -> [v]
-
Returns a list of all the properties, including prototype properties, of the supplied object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
Name Type Description obj
Object The object to extract values from
Returns:
array of the values of the object's own and prototype properties
Example
var F = function() { this.x = 'X'; }; F.prototype.y = 'Y'; var f = new F(); valuesIn(f) // => ['X', 'Y']
-
where :: {k: v} -> {k: v} -> Boolean
-
Takes a spec object and a test object and returns true if the test satisfies the spec. Any property on the spec that is not a function is interpreted as an equality relation.
If the spec has a property mapped to a function, then
where
evaluates the function, passing in the test object's value for the property in question, as well as the whole test object.where
is well suited to declarativley expressing constraints for other functions, e.g.,filter
,find
,pickWith
, etc.Name Type Description spec
Object testObj
Object Example
var spec = {x: 2}; where(spec, {w: 10, x: 2, y: 300}); // => true where(spec, {x: 1, y: 'moo', z: true}); // => false var spec2 = {x: function(val, obj) { return val + obj.y > 10; }; where(spec2, {x: 2, y: 7}); // => false where(spec2, {x: 3, y: 8}); // => true var xs = [{x: 2, y: 1}, {x: 10, y: 2}, {x: 8, y: 3}, {x: 10, y: 4}]; filter(where({x: 10}), xs); // ==> [{x: 10, y: 2}, {x: 10, y: 4}]
-
Wrap a function inside another to allow you to make adjustments to the parameters, or do other processing either before the internal function is called or with its results.
Name Type Description fn
function The function to wrap.
wrapper
function The wrapper function.
Returns:
wrapped function.
Example
var slashify = wrap(flip(add)('/'), function(f, x) { return match(/\/$/)(x) ? x : f(x) });
slashify('a') //= 'a/' slashify('a/') //= 'a/'
-
xprod :: a -> b -> [[a,b]]
-
Creates a new list out of the two supplied by creating each possible pair from the lists.
Name Type Description as
Array The first list.
bs
Array The second list.
Returns:
list made by combining each possible pair fromas
andbs
into pairs ([a, b]
).
Example
xprod([1, 2], ['a', 'b']); //= [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
-
xprodWith :: (a,b -> c) -> a -> b -> [c]
-
Creates a new list out of the two supplied by applying the function to each possible pair in the lists.
Name Type Description fn
function The function to join pairs with.
as
Array The first list.
bs
Array The second list.
- See:
Returns:
list made by combining each possible pair fromas
andbs
usingfn
.
Example
xprodWith(f, [1, 2], ['a', 'b']) //= [f(1, 'a'), f(1, 'b'), f(2, 'a'), f(2, 'b')];
-
zip :: a -> b -> [[a,b]]
-
Creates a new list out of the two supplied by pairing up equally-positioned items from both lists. Note:
zip
is equivalent tozipWith(function(a, b) { return [a, b] })
.Name Type Description list1
Array The first array to consider.
list2
Array The second array to consider.
Returns:
list made by pairing up same-indexed elements oflist1
andlist2
.
Example
zip([1, 2, 3], ['a', 'b', 'c']); //= [[1, 'a'], [2, 'b'], [3, 'c']]
-
zipObj :: k -> v -> {k: v}
-
Creates a new object out of a list of keys and a list of values.
Name Type Description keys
Array The array that will be properties on the output object.
values
Array The list of values on the output object.
Returns:
object made by pairing up same-indexed elements ofkeys
andvalues
.
Example
zipObj(['a', 'b', 'c'], [1, 2, 3]); //= {a: 1, b: 2, c: 3}
-
zipWith :: (a,b -> c) -> a -> b -> [c]
-
Creates a new list out of the two supplied by applying the function to each equally-positioned pair in the lists.
Name Type Description fn
function The function used to combine the two elements into one value.
list1
Array The first array to consider.
list2
Array The second array to consider.
Returns:
list made by combining same-indexed elements oflist1
andlist2
usingfn
.
Example
zipWith(f, [1, 2, 3], ['a', 'b', 'c']); //= [f(1, 'a'), f(2, 'b'), f(3, 'c')]


The start date of your QuantBook
determines the latest date of data you get from history requests. By default, the start date is the current day. To change the start date, call the SetStartDate
method.
qb.SetStartDate(2022, 1, 1);
qb.SetStartDate(2022, 1, 1)
The end date of your QuantBook
should be greater than the end date. By default, the start date is the current day. To change the end date, call the SetEndDate
method.
qb.SetEndDate(2022, 8, 15);
qb.SetEndDate(2022, 8, 15)


|
SDLXX
1.0.0
Modern C++17 wrapper for SDL
|
Class that represents the TrueType font. More...
#include <Font.h>
Public Types | |
| enum | Mode { Mode::SOLID, Mode::SHADED, Mode::BLENDED } |
Public Member Functions | |
| Font (const std::string &file, int point_size, int index=0) | |
| Open a font file and create a Font of the specified point size. More... | |
| ~Font () | |
| Text | render (const std::string &text, Mode mode, const sdlxx::core::Color &color, const sdlxx::core::Color &bg=sdlxx::core::Color(0x00000000)) const |
| Text | render (wchar_t ch, Mode mode, const sdlxx::core::Color &color, const sdlxx::core::Color &bg=sdlxx::core::Color(0x00000000)) const |
Class that represents the TrueType font.
|
strong |
| sdlxx::ttf::Font::Font | ( | const std::string & | file, |
| int | point_size, | ||
| int | index = 0 |
||
| ) |
Open a font file and create a Font of the specified point size.
Some .fon fonts will have several sizes embedded in the file, so the point size becomes the index of choosing which size to load. If the value is too high, the last indexed size will be the default.
| file | Path to the *.ttf or *.fon file |
| point_size | Point size (based on 72 DPI) to load |
| index | Index of font face from a file containing multiple font faces |
| sdlxx::ttf::Font::~Font | ( | ) |
| Text sdlxx::ttf::Font::render | ( | const std::string & | text, |
| Mode | mode, | ||
| const sdlxx::core::Color & | color, | ||
| const sdlxx::core::Color & | bg = sdlxx::core::Color(0x00000000) |
||
| ) | const |
| Text sdlxx::ttf::Font::render | ( | wchar_t | ch, |
| Mode | mode, | ||
| const sdlxx::core::Color & | color, | ||
| const sdlxx::core::Color & | bg = sdlxx::core::Color(0x00000000) |
||
| ) | const |


"JUPITER "the principal deity of the ancient Greeks and Romans. He was worshipped by them under various epithets. Barnabas was identified with this God by the Lycaonians (Acts 14:12), because he was of stately and commanding presence, as they supposed Jupiter to be. There was a temple dedicated to this God outside the gates of Lystra (14:13).
"JUPITER "the principal deity of the ancient Greeks and Romans. He was worshipped by them under various epithets. Barnabas was identified with this God by the Lycaonians (Acts 14:12), because he was of stately and commanding presence, as they supposed Jupiter to be. There was a temple dedicated to this God outside the gates of Lystra (14:13).


In order to run this experiment in the browser you need to to overwrite the module definition to amd using
amd
tsc -p . --module amd
Further more the test.ts is currently expecting a node.js process global variable.
test.ts
process


One
Two
Two
Three
Three
Three
1
2
3
One
Two
Three
Four
Five
1
2
3
One
Two
Two
Three
Three
Three
Four
Four
Four
Four
One
Two
Two
Three
Three
Three
Four
Four
Four
Four
Copy
Save
Save All
Copy All
Copy
Save


Inspiration meets originality on new Surface laptops, designed to light up the best of Windows 11 and adapt to you.
Explore
Send us a message and we will get back to you as soon as possible.


Nyzo version 523 (commit on GitHub) introduces the Nyzo client.
This version affects the client, verifier, and sentinel. The changes to the verifier and the sentinel are inconsequential side effects of changes made in the implementation of the client.
Please realize that this is a minimal version of the client. It does not yet allow sending of transactions. Its tracking of the blockchain is limited and does not yet include any attempt to establish a full history of the blockchain. These limitations will be addressed in future versions.
In ChainInitializationManager, the bootstrapResponses map has been changed to the concurrent version.
Three of the methods used on the initialization process have been narrowed in visibility from public to private. Synchronization has also been removed from one of them; it is no longer necessary due to use of the concurrent hash map. The initialization process that was previously in the Verifier has been encapsulated in the initializeFrozenEdge() method. This was done to allow both the client and verifier to access this code, and it is what allowed narrowing of the visibility of the other methods.
In Message, the fetchFromRandomNode() method has been refactored to allow different behavior in the sentinel and client. This is useful because they each use their own method of tracking which nodes are in the mesh.
In MessageQueue, the log statement has been changed to use the new LogUtil class.
The RunMode enumeration tracks whether the code is running as verifier, sentinel, or client. This is currently used only in the LogUtil class and in the Message.fetchFromRandomNode() method, but it will likely be useful in other places in future versions.
In Verifier, the run mode is set just before the start() method is called. The main() method of the Verifier class is the default entry point of the jar file. This is why the run mode is not set at the top of the main() method as it is in the sentinel and client.
The frozen-edge initialization code that was moved to the ChainInitializationManager class is now accessed through the appropriate method call.
Visibility of the getTrustedEntryPoints() method has been changed to allow access from ClientDataManager.
The client is a simple interactive console application. The program loop asks for which command to run and then collects the necessary arguments and dispatches them to the appropriate command handler. As more functionality is added to the client, it will be encapsulated in separate command handlers for each task.
The ClientDataManager tracks the mesh and blockchain for the client. Use of a democratic process for the Genesis block in addition to the frozen edge means that the client should be able to connect, without modifications, to any Nyzo-based blockchain.
The ClientNodeManager manages mesh information for the client. The verifier, sentinel, and client all need different node managers because they all have different relationships with the mesh. The verifier is an active participant in the mesh. Neither the sentinel nor the client are participants in the mesh, so they must rely on verifiers for mesh information. The sentinel has a fully-trusted relationship with all the verifiers it queries for mesh information, but the client does not.
The Command enumeration is a wrapper for the command handlers. Currently, only four commands are included, and three of those are system commands (i.e., not actual tasks). The only useful command in this version is balance. In the lines commented out, you can see some of the other commands currently in development.
The ConsoleColor enumeration provides simple ANSI console coloring. This is disabled by default, as non-ANSI consoles display erroneous characters for ANSI color commands. To enable this functionality, place the line enable_console_color=1 in /var/lib/nyzo/production/preferences.
The ConsoleUtil class provides a simple mechanism for printing tables of data.
The BalanceDisplayCommandHandler displays the balances of accounts with a specified prefix at the current local frozen edge. This is the only command handler of utility in this version of the client.
The CommandHandler interface will be used for all the commands in the client. Separation of the argument names from execution of the handler will allow different interfaces, including a web interface, to share the same command handler.
The EmptyCommandHandler prints the available commands if no command is provided.
The ExitCommandHandler terminates the client.
The InvalidCommandHandler is similar to the EmptyCommandHandler, but it also provides feedback that an invalid command was provided.
The sentinel, like the client, sets the run mode at the top of the main() method.
The sentinel block-with-votes fallback now uses the run-mode-aware Message.fetchFromRandomNode() method.
The randomNode() method has been changed to public visibility to allow access from the Message class.
The LogUtil class suppresses console output for messages in the client run mode. Like some other classes introduced in this version, this class is little more than a placeholder for planned future functionality.
PreferencesUtil has a new getBoolean() method. This method is used by ConsoleColor to activate the color codes.
To use the client, follow the installation instructions for the verifier. Then, run the following command from the nyzoVerifier directory:
sudo java -jar build/libs/nyzoVerifier-1.0.jar co.nyzo.verifier.client.Client


FLL INTO ORBIT Scorer
INTO ORBIT SCORER (TITLE IN LANGUAGES.JS)
Timer:
2:30
Start
Reset
Stop
Stopwatch:
00:00.0
Start
Reset
Stop
Saving System:
Google Sheets (Default)
Local Browser Storage (Legacy)
Team
#:
Round
#:
Index
#:
Back Home
Sign in
Sign Out
Save Score
Scorer
Saves
Timers
Points
:
0
INTO ORBIT Scorer Revision
1.4 Tournament Scorer r2.3
Copyright (c) 2018 Seshan Brothers


MY SPEECH
Friends, family, rabbis, spirits & honoured guests, I hope you are enjoying yourselves so far.
Before I get into the grit of the speech, I must give a few, and I will try to seriously make it a few, essential and special thankyous. First and foremost, I must thank my great-grandmother for surviving to this day, and Nana Felka I want you to know that we are all honoured to have you here with us. I hope you are as happy as we are that youre here.
I must give a special thankyou to Rabbi Zalman (hope that isnt too formal), for teaching me all year and for being here tonight. Zalman has put as much work into this occasion as I have, if not more, and without him I dont know how I would have managed to learn everything I needed to know.
My own mum gets a special thankyou for arranging the whole thing. If not for her, I doubt that we would be here and everything would be organised. Mummy has many different qualifications, including real estate stickybeak, holiday organiser, barmitzvah veteran, schlepper, and of course, being a mummy. In this major operation my mum has proven her true natural ability of organisation, and she deserves a big round of applause.
After the boss there comes my dad, who is also qualified in different areas. Apart from being a shul schlepper every Friday night & Saturday, Daddy is a go-to-bed and have-a-shower pro, an efficient worrier, a TV schloofer and a computer illiterate. Oh yeah, and a barrister, but thats only something minor.
I have one apology from a person that would like to be here, but couldnt quite make it. My dog Boo would have loved to have been here, but the caterers dont specialize in chicken wings and brisket bones, and we also didnt like the idea of throwing a tennis ball across the room right through dinner. We also couldnt afford to get carpet cleaners to clean away the inevitable muddy pawprints, but I assure you that Boo would be here if not for these technical problems.
Unfortunately my Nona & Nono arent here to see me either. Im sure they would have been proud of me, and Nona is definitely here in spirit. Nono could not come from the Montefiore home, as he isnt well enough, but when I saw him this morning he wished me mazal tov.
Thankyou tonnes Nana & Poppy for making it to this day. Poppy, over the years you have bought me watches, taken me to the movies, you have taught me the American chopsticks and given me advice, and it was indeed a great honour to have a kohen for a grandad yesterday! Nana, thanks for all the years I slept over, for all your orange cakes and for the countless swims weve had for all the Sunday afternoons in all the summers I can remember!
You may be surprised, but I do actually have something to say apart from thanking everyone for being here. Dad has already done most of them, and besides this is meant to be a speech, not a lullaby to put you to sleep. I would like to tell you all what this day really means to me.
Today, or yesterday, was the day that I finished being a Jewish boy and started my life as a Jewish man. The first of many things this means is that my parents are no longer responsible for what I do, and it is no longer up to them to teach me about Judaism and encourage me to be a good observant Jew. Of course, they have made it pretty easy for me, as they have encouraged me and taught me more than enough for me to keep going on my own. But it is now up to me to use my own initiative to participate in Jewish activities, to keep going to shule and to keep mitzvot. If I dont do these things, you cant blame my parents.
Another thing this means is that I can now be counted as part on a minyan. This is great, because it means that when we go to shule and there are 9 men there, I dont have to hold a chumash anymore!
In my parsha, parshas Bo, g-d quotes: "For seven days you shall eat matzos" (Shemos 12:15). This is where g-d commands us to eat matzos, and as it is a comandment and a mitzvah, we should do everything in our power to fulfil it. To show you just how important it is to eat matzos, I would like to tell you a story.
A young Boch had been training in Yeshiva when WWII began. The boy, whose name was Chaim, had been captured by the Germans, but by a miracle had escaped. He had come to Lublin, in Poland, which was controlled by the Russians at that time. He met his family there, but when they were reunited they were given a choice of becoming Russian citizens or living in Siberia. They chose Siberia, as they would one day have more chance of escaping from there.
Chaim, his father and brother were in the same barracks in Siberia, and were forced to live in bad conditions and do hard work. Although they were not allowed to keep any mitzvahs, Chaim did manage to put on tefillin every day. When he was caught once and the guard tried to take away his tefillin, Chaim said hed rather be shot than give them away.
Unfortunately, when Pesach came Chaim did not know what to do. The only food they received was stale bread, and they didnt know how they could stay alive without eating chametz. They had been sent some matzah and wine from the American rescue committee, but not enough to last them all through Pesach.
Chaim had one idea. The one thing they still owned was his fathers fur coat, and if they could sell it for some non-chametz food, they would be able to survive Pesach. So one day, when a wagon came through the camp laden with fruit and vegetables, Chaim traded a few bags of the parcels for his fathers coat.
When Pesach began a few days later, all the Jews in the camp were gathered in one tent for a seder. They were eating and singing happily, when a guard stormed into the room. He was appalled that they dare do this, and immediately accused Chaim of starting the seder, and put him in a prison cell in isolation. Chaim prayed to g-d that he would be rewarded for his good deed some day, and hoped that he had not gone to all the trouble to keep the seder for nothing.
In reward for his good deed that night, Chaim was freed from the barracks. He eventually settled in America, where his children are well known for their good services to this day.
This story teaches me that when we do a mitzvah, we will be well rewarded for it some day, and we should be willing to sacrifice as many luxuries as we must to keep g-ds mitzvahs.
Finally, I would like to evaluate my bar mitzvah and see what I have learnt from it, and what I can continue to do now that its finished (well, almost finished). In this year I have learnt many prayers, I have learnt to follow a service, and I have learnt the meaning of some prayers. Some of the sections of my Parsha have been hammered into me so well that I could say them 20 years from now! I have learnt how to use my Da-at, which is the power not only to know and understand concepts, but to learn from them and to realize their significance. Once again I must thank Zalman for bringing out the Da-at within me, and within some friends that I have been learning with.
I have decided that I will keep the mitzvah of putting on tefillin, and will put them on at least once a week. I will give some money to tzedakah every day, and will continue to go to shule on Shabbat.
Copyright 1998 Jeremy Epstein. This site is a member of the JazaWeb Network.


--- layout: default ---
Much like the right to interracial marriage, woman's suffrage, freedom of speech, and many others, we didn't always have the right to privacy. In several dictatorships, many still don't. Generations before ours fought for our right to privacy. Privacy is a human right inherent to all of us, that we are entitled to without discrimination.
You shouldn't confuse privacy with secrecy. We know what happens in the bathroom, but you still close the door. That's because you want privacy, not secrecy. Everyone has something to hide, privacy is something that makes you human.
Trying to protect all your data from everyone all the time is impractical, expensive, and exhausting. But, don't worry! Security is a process, and by thinking ahead you can put together a plan that's right for you. Security isn't just about the tools you use or the software you download. Rather, it begins with understanding the unique threats you face, and how you can counter them.
This process of identifying threats and defining countermeasures is called threat modeling, and it forms the basis of every good security and privacy plan.
Learn More About Threat ModelingIt's important for a website like Privacy Guides to always stay up-to-date. We need our audience to keep an eye on software updates for the applications listed on our site and follow recent news about providers that we recommend. We try our best to keep up, but we're not perfect and the internet is changing fast. If you find an error, or you think a provider should not be listed here, or a qualified service provider is missing, or a browser plugin is not the best choice anymore, or anything else... Talk to us please.


Rakesh R
Full stack web developer
Project One
Udacity Front-end Web development Nanodegree
www.github.com
Project Two
Udacity Front-end Web development Nanodegree
www.github.com
Project Three
Udacity Front-end Web development Nanodegree
www.github.com