add illustration samples

This commit is contained in:
Oli Sturm
2022-07-22 15:00:53 +01:00
parent 0a28574514
commit 250d86bafa
5 changed files with 58 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
-- This function uses a boolean guard and defines
-- its value only for the remaining cases.
fact :: Int -> Int
fact x | x <= 1 = 1
| otherwise = x * (fact (x - 1))
-- Alternatively, pattern matching can be used for an
-- even more explicit declaration.
fact' :: Int -> Int
fact' 0 = 1
fact' 1 = 1
fact' x = x * (fact (x - 1))