CIS194/Lecture 01/scratch/sumFun.hs

11 lines
187 B
Haskell
Raw Permalink Normal View History

2016-09-22 21:50:31 +00:00
sumFun :: Integer -> Integer
sumFun 0 = 0
sumFun n
| n < 0 = 0
| otherwise = sumFun(n - 1) + n
sumList :: Integer -> [Integer]
sumList 0 = []
sumList n = sumFun(n) : sumList(n - 1)