Based on Haskell for Javascript programmers by Tsoding
- A list is made by nesting pairs
[1,2,3,4,5] = (1,(2,(3,(4,(5,null)))))
- Use recursion since we can't use loops
- No loops
- No ifs
- Function is a single return
- No side effects
- No assignments in functions
- No arrays
- Only functions with 0 or 1 arguments
//Create a pair of objects from 1 to 10
let xs=range(1)(10)
//Print their sum
console.log(sum(xs))
//Strings are just an array of characters
//Convert an array to a pair data type then print it
let monicaPair=arrayToPair("Just Monika")
console.log(monicaPair)
//FizzBuzz from 1 to 100
pairToArray(map(fizzBuzz)(range(1)(100)))