haskell - It works when loaded from file, but not when typed into ghci. Why? -
if put following 2 lines foobar.hs
f 1 = 1 f x = f (x-1)
then
$ ghci > :load foobar.hs > f 5 1
but if do
$ ghci > let f 1 = 1 > let f x = f (x-1) > f 5 ^cinterrupted.
then not return. why?
the latter binding overrides former. use in ghci:
prelude> :{ prelude| let f 1 = 1 prelude| f x = f (x-1) prelude| :} prelude> f 5 1
or, without layout:
prelude> let f 1 = 1; f x = f (x-1) prelude> f 5 1
Comments
Post a Comment