add illustration samples
This commit is contained in:
@@ -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))
|
||||
Reference in New Issue
Block a user