[Haskell-beginners] Can you identify this recursion pattern please?

Colin Paul Adams colin at colina.demon.co.uk
Tue Sep 29 13:02:40 EDT 2009


This looks like some kind of unfold to me. Can you help?

I have the following code that works for the first two levels:

  -- get the list of all (recursive) child gallery names
  -- first, just the immediate children
  childNames <- childGalleries db (name gallery)
  -- now let's try the next level
  grandchildren <- mapM (childGalleries db) childNames
  mapM putStrLn (childNames ++ concat grandchildren)

The database query childGalleries gives me a list of all the immediate
children.
So what I want is recursively, the names of all the descendants, as
well as the original name, concatenated to a flat list. I'm struggling
to identify the higher-order recursion function I need.
-- 
Colin Adams
Preston Lancashire


More information about the Beginners mailing list