Skip to content

Pure function practice, from Haskell youtube video, which talks about Javascript, implement with Swift

Notifications You must be signed in to change notification settings

ytyubox/pure-function-fizzbuzz-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HaskellLikeFizz

Swift implement of Haskell Fizz buzz from youtube: Haskell for JavaScript programmers - YouTube

Principles

Pure functional programming is about composing pure functions.

  1. No Loops
  2. No ifs
  3. Function is Single Return
  4. No side-effects
  5. No Assignments in Function
  6. No arrays
  7. Only Functions with 0 or 1 arguments

Result:

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
]
*/

About

Pure function practice, from Haskell youtube video, which talks about Javascript, implement with Swift

Topics

Resources

Stars

Watchers

Forks

Languages