[Haskell] Queues / Lists with unbound tails

andrew cooke andrew at acooke.org
Sat May 8 12:18:34 EDT 2004


Claus Reinke said:
[...]
> something like this?
>
> initQ n       = foldr (.) id $ take n $ repeat (Nothing:)
> pushQ front q = tail . q . (front:)
> peekQ q       = (head $ q [], q)

Yes, thanks.  At least, it looks easy to get what I want from that.

Sigh.  It seems so obvious now.  When will this fucntional programming /
laziness deal finally become completely clear?

Cheers,
Andrew

-- 
` __ _ __ ___  ___| |_____   work web site: http://www.ctio.noao.edu/~andrew
 / _` / _/ _ \/ _ \ / / -_)  personal web site: http://www.acooke.org/andrew
 \__,_\__\___/\___/_\_\___|  list: http://www.acooke.org/andrew/compute.html



More information about the Haskell mailing list