2013-08-11 AM10:26 +0800,"Nala Ginru" <[email protected]> : > > 2013-8-11 AM9:46,"kang qiao" <[email protected]>: > > > > Thank you.It seems Guile implements a simple queue > > structure by (cons first-pair last-pair) and > > providing some basic functions.I can use it. > > > > One more question, maybe redundant: > > I came across Haskell a few months ago. > > In Haskell, we do collect just use recursion, > > like this: > > myFilter :: (a -> Bool) -> [a] -> [a] > > myFilter _ [] = [] > > myFilter f (x:xs) > > | (f x) = x : rest > > | otherwise = rest > > where rest = myFilter f xs > > myFilter (<=10) [1,33,42,2,7,10] > > ==> [1,2,7,10] > > That's the most common way.You don't need > > to worry about stack consuming. > > Is it really take much space in stack, or > > Haskell will do some optimizing? > > > > Are you talking about tail recursive? > This mail-list is not for haskell, but if it's the most common way for > haskell, I think it has tail recursive optimization. > > > > >
I don't think it is tail recursion. Because tail recursing will always return the result of the latest call, but we don't return it but link(I mean cons) the previous result to it. (note ':' in Haskell is an infix operator, it means cons)
