Swift implement of Haskell Fizz buzz from youtube: Haskell for JavaScript programmers - YouTube
Pure functional programming is about composing pure functions.
- No Loops
- No ifs
- Function is Single Return
- No side-effects
- No Assignments in Function
- No arrays
- Only Functions with 0 or 1 arguments
list2array(map(fizzbuzz(_:))(range(1)(20)))
/*
[
"1",
"2",
"fizz", // 3 is multiple 3
"4",
"buzz", // 5 is multiple 5
"fizz", // 6 is multiple 3
"7",
"8",
"fizz", // 9 is multiple 3
"buzz", // 10 is multiple 5
"11",
"fizz", // 12 is multiple 3
"13",
"14",
"fizzbuzz", // 15 is multiple 3 and 5
"16",
"17",
"fizz", // 18 is multiple 3
"19",
"buzz" // 20 is multiple 5
]
*/