guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Which is the best way to collect lists?


From: Nala Ginrut
Subject: Re: Which is the best way to collect lists?
Date: Sun, 11 Aug 2013 10:55:47 +0800


2013-8-11 AM10:51,"kang qiao" <address@hidden>:
>
> 2013-08-11 AM10:26 +0800,"Nala Ginru" <address@hidden> :
> >
> > 2013-8-11 AM9:46,"kang qiao" <address@hidden>:
> > >
> > > 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)
>

I don't understand your question, maybe you should ask it in haskell list.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]