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: kang qiao
Subject: Re: Which is the best way to collect lists?
Date: Sun, 11 Aug 2013 09:45:37 +0800

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?




reply via email to

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