From: ross Date: Wed, 26 Oct 2005 22:52:58 +0000 (+0000) Subject: [project @ 2005-10-26 22:52:58 by ross] X-Git-Tag: Initial_conversion_from_CVS_complete~28 X-Git-Url: http://git.megacz.com/?p=haskell-directory.git;a=commitdiff_plain;h=13e58f0482069d84b89d90eeeeca2c172c3e6682 [project @ 2005-10-26 22:52:58 by ross] missing part of rev. 1.13: in unfoldForestM_BF, the output sequence is now in the right order, so don't reverse it. --- diff --git a/Data/Tree.hs b/Data/Tree.hs index 113bc4c..5a30470 100644 --- a/Data/Tree.hs +++ b/Data/Tree.hs @@ -29,9 +29,8 @@ import Prelude #endif import Control.Monad -import Data.Sequence (Seq, empty, singleton, (<|), (|>), fromList, +import Data.Sequence (Seq, empty, singleton, (<|), (|>), fromList, toList, ViewL(..), ViewR(..), viewl, viewr) -import qualified Data.Sequence as Seq (foldl) import Data.Typeable #include "Typeable.h" @@ -123,9 +122,7 @@ unfoldTreeM_BF f b = liftM getElement $ unfoldForestQ f (singleton b) -- /Breadth-First Numbering: Lessons from a Small Exercise in Algorithm Design/, -- by Chris Okasaki, /ICFP'00/. unfoldForestM_BF :: Monad m => (b -> m (a, [b])) -> [b] -> m (Forest a) -unfoldForestM_BF f = liftM toRevList . unfoldForestQ f . fromList - where toRevList :: Seq c -> [c] - toRevList = Seq.foldl (flip (:)) [] +unfoldForestM_BF f = liftM toList . unfoldForestQ f . fromList -- takes a sequence (queue) of seeds -- produces a sequence (reversed queue) of trees of the same length