mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-14 05:05:59 +00:00
This commit is contained in:
parent
d064763e95
commit
0a0080a955
@ -152,7 +152,7 @@ fib x
|
|||||||
| otherwise = fib (x - 1) + fib (x - 2)
|
| otherwise = fib (x - 1) + fib (x - 2)
|
||||||
|
|
||||||
-- Pattern matching is similar. Here we have given three different
|
-- Pattern matching is similar. Here we have given three different
|
||||||
-- equations for fib. Haskell will automatically use the first
|
-- equations that define fib. Haskell will automatically use the first
|
||||||
-- equation whose left hand side pattern matches the value.
|
-- equation whose left hand side pattern matches the value.
|
||||||
fib 1 = 1
|
fib 1 = 1
|
||||||
fib 2 = 2
|
fib 2 = 2
|
||||||
@ -198,7 +198,7 @@ foo 5 -- 15
|
|||||||
-- multiplies the result of that by 4, and then returns the final value.
|
-- multiplies the result of that by 4, and then returns the final value.
|
||||||
foo = (4*) . (10+)
|
foo = (4*) . (10+)
|
||||||
|
|
||||||
-- 4*(10+ 5) = 60
|
-- 4*(10+5) = 60
|
||||||
foo 5 -- 60
|
foo 5 -- 60
|
||||||
|
|
||||||
-- fixing precedence
|
-- fixing precedence
|
||||||
|
Loading…
Reference in New Issue
Block a user