and


a → b → a | b

Added in v0.1.0

Returns the first argument if it is falsy, otherwise the second argument. Acts as the boolean and statement if both inputs are Booleans.

See also both, or.

  1. R.and(true, true); //=> true
  2. R.and(true, false); //=> false
  3. R.and(false, true); //=> false
  4. R.and(false, false); //=> false

isEmpty


a → Boolean

Added in v0.1.0

Returns true if the given value is its type’s empty value; false otherwise.

See also empty, isNotEmpty.

  1. R.isEmpty([1, 2, 3]); //=> false
  2. R.isEmpty([]); //=> true
  3. R.isEmpty(''); //=> true
  4. R.isEmpty(null); //=> false
  5. R.isEmpty({}); //=> true
  6. R.isEmpty({length: 0}); //=> false
  7. R.isEmpty(Uint8Array.from('')); //=> true

not


* → Boolean

Parameters

  • aany value

Returns Boolean the logical inverse of passed argument.

Added in v0.1.0

A function that returns the ! of its argument. It will return true when passed false-y value, and false when passed a truth-y one.

See also complement.

  1. R.not(true); //=> false
  2. R.not(false); //=> true
  3. R.not(0); //=> true
  4. R.not(1); //=> false

or


a → b → a | b

Added in v0.1.0

Returns the first argument if it is truthy, otherwise the second argument. Acts as the boolean or statement if both inputs are Booleans.

See also either, and.

  1. R.or(true, true); //=> true
  2. R.or(true, false); //=> true
  3. R.or(false, true); //=> true
  4. R.or(false, false); //=> false

cond


[[(*… → Boolean),(*… → *)]] → (*… → *)

Parameters

  • pairsA list of [predicate, transformer]

Returns function

Added in v0.6.0

Returns a function, fn, which encapsulates if/else, if/else, ... logic. R.cond takes a list of [predicate, transformer] pairs. All of the arguments to fn are applied to each of the predicates in turn until one returns a “truthy” value, at which point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates matches, fn returns undefined.

Please note: This is not a direct substitute for a switch statement. Remember that both elements of every pair passed to cond are functions, and cond returns a function.

See also ifElse, unless, when.

  1. const fn = R.cond([
  2. [R.equals(0), R.always('water freezes at 0°C')],
  3. [R.equals(100), R.always('water boils at 100°C')],
  4. [R.T, temp => 'nothing special happens at ' + temp + '°C']
  5. ]);
  6. fn(0); //=> 'water freezes at 0°C'
  7. fn(50); //=> 'nothing special happens at 50°C'
  8. fn(100); //=> 'water boils at 100°C'