Simple Another nice feature of Haskell is pattern matching. I glossed over it in the Fibonacci function, so let’s review. fib :: (Integral t) => t -> t fib 0 = 1 fib 1 = 1 fib n = fib (n – 1) + fib (n – 2) Analogous code in Java would be: public […]
/ Blog | |
Tag Archives: pattern matchingAdventures in Haskell – Pattern MatchingPosted March 18, 2010 – 5:11 pmSimple Another nice feature of Haskell is pattern matching. I glossed over it in the Fibonacci function, so let’s review. fib :: (Integral t) => t -> t fib 0 = 1 fib 1 = 1 fib n = fib (n – 1) + fib (n – 2) Analogous code in Java would be: public […] |
|
This website contains my own opinions and does not reflect the opinions of anyone else. I do not guarantee that any information on this site is accurate. Use at your own risk. Content is subject to change or removal without notice. All rights reserved. Slippery when wet. May contain peanuts. |