[Haskell-beginners] Query regarding an unusually behaving code
Theodore Lief Gannon
tanuki at gmail.com
Sun Nov 15 04:42:53 UTC 2015
GHCi doesn't quite support everything you could put in a source file. To do
what you want here, you need to use Haskell's alternative block syntax:
:{
let { digs 0 = [0]
; digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
}
:}
...yep, curly braces and semicolons just like C-family. :) It's intended
for machine-generated code, but works for this too. And in fact you
actually don't need multi-line, this is legal:
let { digs 0 = [0]; digs x = (digs (x `div` 10)) ++ [(x `rem` 10)] }
On Sat, Nov 14, 2015 at 9:35 PM, <amindfv at gmail.com> wrote:
> In ghci you want to make a multi-line expression:
>
> :{
> let digs 0 =[0]
> digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
> :}
>
> (Note we don't put "let" on the second line)
>
> tom
>
>
> > El 13 nov 2015, a las 01:47, akash g <akaberto at gmail.com> escribió:
> >
> > let digs 0 =[0]
> > let digs x = (digs (x `div` 10)) ++ [(x `rem` 10)]
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/beginners/attachments/20151114/a21d9dfc/attachment.html>
More information about the Beginners
mailing list