Skip to content

Latest commit

 

History

History
113 lines (66 loc) · 1.5 KB

README.md

File metadata and controls

113 lines (66 loc) · 1.5 KB

Table of Contents

car

Get the first element of the pair (car)

Parameters

  • pair Pair<A, B>

Examples

const pair = cons(5, 'hello');

car(pair); // 5

Returns A

cdr

Get the second element of the pair (cdr)

Parameters

  • pair Pair<A, B>

Examples

const pair = cons(5, 'hello');

cdr(pair); // hello

Returns B

cons

Pair constructor (cons)

Parameters

  • a A
  • b B

Examples

const pair = cons(5, 'hello');
const pair = cons(cons(1, null), 'world');

Returns Pair<A, B>

isPair

Check if the passed argument is a pair (isPair)

Parameters

  • cons Pair<A, B>

Examples

const pair = cons(5, 'hello');

isPair(pair); // true
isPair(5); // false

Returns boolean

stringify

Convert a pair to a string (toString)

Parameters

  • pair Pair<A, B>

Examples

toString(cons('', 10)); // "('', 10)"
toString(cons('one', 'two')); // "('one', 'two')"

Returns string