
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

On Nov 9, 2011, at 12:18 AM, 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.
Your code is quite complex for the task. Your analysis that the problem lies with foldl' not consuming the whole list is extremely unlikely. Probably, the problem is elsewhere. Try building your solution more from the bottom up and unit testing the components.

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
participants (3)
-
Alexander V Vershilov
-
David Place
-
Lev Broido