@rgeraldporter/

List Monad Example

Nodejs

No description

fork
loading
Files
  • index.js
  • List.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const { List } = require('./List');

const myNumbers = List.of([1, 3, 4, 7, 10]);

// uncomment a console.log below to see the value

//console.log(myNumbers.inspect())
// > List(1,3,4,7,10)

//console.log(myNumbers.concat([12]).inspect())
// > List(1, 3, 4, 7, 10, 12);

//console.log(myNumbers.head())
// > 1

// Excercise: make a `.tail()` method on the List.js file, which returns the last item of the list
node v10.16.0