[erlang-questions] newbie question

Ukyo Virgden listproc@REDACTED
Wed Nov 28 23:04:48 CET 2007


Hi,

I've just jumped into Erlang. Almost finished reading Joe Armstrong's  
book. While testing with mnesia, I've come across a problem I hope  
you guys can shed a light.

Consider I have records like (count, item, user)

{4, apple, john}
{7, apple, mary}
{3, oranges, jane}
{2, oranges, john}
{2, bananas, mary}
{5, bananas, jane}
{2, bananas, john}

I can store in mnesia and retrieve with qlc. But I could not "group"  
them. I figured out how inappropriate it'd be to ask is qlc has a  
facility like SQL GROUP BY. :)

Can anybody help me how can I group returned list? Or in other words,  
how can I apply an aggregate function to get sum of items, count of  
items etc.? I've already figured out I can send my process some  
messages and collect data but I believe that'd be slower than being  
able to write a recursive function.

I'd appreciate if you could provide some pointers to resources for  
functional programming techniques in Erlang.

Thanks in advance
Ukyo Virgden





More information about the erlang-questions mailing list