diff options
author | Braxton Hall | 2022-10-24 19:25:22 +0000 |
---|---|---|
committer | GitHub | 2022-10-24 19:25:22 +0000 |
commit | 13fc2738b971774a3af451e63fcb34e8010fadc5 (patch) | |
tree | 4e505bf436dd754d814017e279b40a1d49191089 | |
parent | 0ed78b5a990776b0db8c794b4e9ca415fee86fce (diff) | |
parent | a9e39fa02410b61288208509e038b9e096486702 (diff) |
Merge pull request #22 from zgrannan/main
Add submission for zgrannan
-rw-r--r-- | entries/zgrannan/Fib.hs | 18 | ||||
-rw-r--r-- | people.json | 11 |
2 files changed, 29 insertions, 0 deletions
diff --git a/entries/zgrannan/Fib.hs b/entries/zgrannan/Fib.hs new file mode 100644 index 0000000..1918fc8 --- /dev/null +++ b/entries/zgrannan/Fib.hs @@ -0,0 +1,18 @@ +-- Point-less fibonacci +fib :: Int -> Int +fib = fix fib' + where + fib' = + ap (when 0 . (0 ==)) . + ap (when 1 . (1 ==)) . + ap (ap . ((+) .) . (. subtract 1)) (. subtract 2) + + when t c e = if c then t else e + + ap mf m = mf >>= (\f -> m >>= return . f) + + fix f = f (fix f) + + +main :: IO () +main = mapM_ (print . fib) [0 .. 10] diff --git a/people.json b/people.json index 26dc1db..cd0cb50 100644 --- a/people.json +++ b/people.json @@ -213,5 +213,16 @@ "link": "./entries/laelath/fib.bf" } ] + }, + { + "github": "zgrannan", + "name": "Zack Grannan", + "title": "MSc Computer Science Student, UBC", + "entries": [ + { + "name": "haskell", + "link": "./entries/zgrannan/Fib.hs" + } + ] } ] |