[erlang-questions] Using a queue

yoursurrogategod <>
Tue Aug 26 01:53:34 CEST 2008


I'm trying to use the queue module in Erlang by trying it out in the
console. Here is what I tried and here are the results:

34> T1 = queue:new().
{[],[]}
35> queue:in("foo", T1).
{["foo"],[]}
36> queue:in("bar", T1).
{["bar"],[]}
37> queue:out(T1).
{empty,{[],[]}}
38> queue:out(T1).
{empty,{[],[]}}
39> queue:out(T1).
{empty,{[],[]}}
40> queue:in("foo", T1).
{["foo"],[]}
41> queue:out(T1).
{empty,{[],[]}}


What confuses me here is that I expected foo and bar to be somehow
next to one another after inserting bar. Why is it that it's only foo?

Also, I have another question. I would like a linked list in Erlang
(similar to the STL list class in C++), is there something like that?
It would be also nice if the individual elements in the said list
could be accessed in a similar fashion as an array :) (don't know if
this is possible).



More information about the erlang-questions mailing list