in-ram lists

Damir Horvat <>
Fri Mar 24 14:26:56 CET 2006

On Fri, Mar 24, 2006 at 01:48:06PM +0100, R?mi H?rilier wrote:

> Don't forget to get the value returned by queue:in(Item,Queue).
> 1> Q1 = queue:new().
> {[],[]}
> 2> Q2 = queue:in("item1", Q1).
> {["item1"],[]}
> 3> Q3 = queue:in("item2", Q2).
> {["item2"],["item1"]}
> 4>

Ok, I get this. But what bothers me is, how to do this in functional

I'd like to have this queue accessible in ram. I'd like to have two
functions (push, shift) which adds new element to the queue and takes
one off. I don't want to worry about naming variables to capture return

For example:

push (element, queue) # puts element on the tail of the queue
shift (queue) # gets first element from the queue.

That's all I need. Is this doable in erlang?

More information about the erlang-questions mailing list