[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:26:39 +0800 |
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.
>