Skip to content

Instantly share code, notes, and snippets.

@gouthamve
Last active January 17, 2016 06:36
Show Gist options
  • Save gouthamve/80605559f03159e0e7d4 to your computer and use it in GitHub Desktop.
Save gouthamve/80605559f03159e0e7d4 to your computer and use it in GitHub Desktop.
Why does this happen?
-- Doesnt Work
module Foo where
sumTutorial :: Integer -> Integer
sumTutorial 0 = 0
sumTutorial n = n + sumTutorial n-1
module Foo where
sumTutorial :: Integer -> Integer
sumTutorial n
| n == 0 = 0
| otherwise = n + sumTutorial n-1
-- Works
module Foo where
sumTutorial :: Integer -> Integer
sumTutorial 0 = 0
sumTutorial n = n + sumTutorial (n-1)
module Foo where
sumTutorial :: Integer -> Integer
sumTutorial n
| n == 0 = 0
| otherwise = n + sumTutorial (n-1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment