[Haskell-beginners] can this be made shorter?

Sylvain HENRY hsyl20 at gmail.com
Fri Jun 21 13:14:27 CEST 2013


>    afaik in scala you can say:
>
> null . dropWhile (_ == '.' || _ == '/')
>
>    which is a bit more compact than the haskell...

No, it would be desugared to:
dropWhile ((a,b) => a == '.' || b == '/')

scala> "abc".dropWhile(_ == '.' || _ == '/')
<console>:8: error: wrong number of parameters; expected = 1
               "abc".dropWhile(_ == '.' || _ == '/')

You would have to do the same thing as in Haskell to make it work:

scala> "abc".dropWhile(a => a == '.' || a == '/')
res20: String = abc

Cheers
Sylvain



More information about the Beginners mailing list