in-ram lists

orbitz@REDACTED orbitz@REDACTED
Fri Mar 24 15:11:43 CET 2006


You can always write a process to handle this stuff.  If you "don't 
want to worry about naming variables to capture return values" then 
perhaps you are using the wrong language paradigm.

On Mar 24, 2006, at 8:26 AM, Damir Horvat wrote:

> 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
> way?
>
> 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
> values.
>
> 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