[Haskell-beginners] Help : foldl skipping one value in list
Alexander V Vershilov
alexander.vershilov at gmail.com
Thu Nov 10 05:39:21 CET 2011
Hello.
Wed, Nov 09, 2011 at 07:18:14AM +0200, Lev Broido wrote
> Hi
> I am implementing toy loop search algorithm in graph .
> I encountered strange problem -- it seems , that fold doesn't run on the
> whole list .
> Code is at http://hpaste.org/53776
> Section in question is updVis function
> Problem occurs when _newStateMap_2 is being calculated
> Please advise.
>
> Thanks,
> Lev
>
I have not checked all pasted code but for your problem you can try
next solution (using Either to specify is it odd or even argument):
> f = foldl (\x y -> inner x y) (Left [])
> where
> inner (Left xs) _ = Right xs
> inner (Right xs) y = Left (yourfunction y:xs)
--
Alexander V Vershilov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20111110/b0e1dd6d/attachment.pgp>
More information about the Beginners
mailing list