[Haskell-beginners] can this be made shorter?
Emmanuel Touzery
etouzery at gmail.com
Wed May 29 21:50:08 CEST 2013
Thank you, that's exactly what I was looking for!
I didn't spot "elem" so far... that's why I was looking into "and" which
was too complex for this case.
Thanks again!
emmanuel
On Wed, May 29, 2013 at 9:44 PM, Felipe Almeida Lessa <
felipe.lessa at gmail.com> wrote:
> Well, you could use:
>
> null . dropWhile (`elem` "./")
>
> =)
>
> On Wed, May 29, 2013 at 4:38 PM, Emmanuel Touzery <etouzery at gmail.com>
> wrote:
> > hi,
> >
> > i want to know if a string contains only "." and "/" characters.
> >
> > i do something like that:
> >
> > null . dropWhile (\c -> c == '.' || c == '/')
> >
> > now it's a shame, because if I wanted only to check for "." then I
> would
> > have:
> >
> > null . dropWhile (=='.')
> >
> > afaik in scala you can say:
> >
> > null . dropWhile (_ == '.' || _ == '/')
> >
> > which is a bit more compact than the haskell...
> >
> > I was thinking to use "and" but I'm not sure it would end up being
> > readable...
> >
> > Any idea? Or I am trying too hard to make it compact?
> >
> > Emmanuel
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at haskell.org
> > http://www.haskell.org/mailman/listinfo/beginners
> >
>
>
>
> --
> Felipe.
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20130529/afae668d/attachment-0001.htm>
More information about the Beginners
mailing list