[Haskell-beginners] Re: mayBe stuck

Dean Herington heringtonlacey at mindspring.com
Fri Aug 6 03:43:30 EDT 2010


At 8:34 PM -0700 8/5/10, prad wrote:
>On Thu, 5 Aug 2010 19:07:13 -0700
>prad <prad at towardsfreedom.com> wrote:
>
>>  correcting it by sticking on a
>>  delimiter doesn't seem to be the right thing to do though. so there
>>  must be another way to deal with this. hmmm.
>>
>i think i can solve the dilemma by introducing an accessory function
>getTail:
>
>br []       = []
>br ss       = fst (tup) : br (getTail (snd tup))
>     where
>         tup     = break eqD ss
>         getTail s
>             | s==[]     = []
>             | otherwise = tail s
>
>it works, though i don't know if this is necessarily the best way to do
>it.
>
>--
>In friendship,
>prad

I would write something like:

br [] = []
br ss = let (h, t) = break eqD ss
         in h : case t of
                  []    -> []
                  _ : t -> br t

Dean


More information about the Beginners mailing list