[mercury-users] Converting List To List Of Tuples

win1for at yahoo.com win1for at yahoo.com
Fri Dec 17 15:22:26 AEDT 2010

 I am just a total beginner in mercury and finding it hard to 
solve this problem. I want to convert a list to a list of tupples sorted
 from smaller to higher frequenties.  Eg:

string.to_char_list("this is a test")  becomes

[{'a', 1}, {'e', 1}, {'h', 1}, {'i', 2}, {' ', 3}, {'s', 3}, {'t', 3}]


[3,2,1,2,1,1,2]  becomes

[{3, 1}, {1, 3}, {2, 3}]

You can see that the list of tuples are sorted from smaller to higher frequenties.

I am asking if someone can help me to solve this or  point me to a tutorial where i can find more tips to do it.

Thanks for your reply.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurylang.org/archives/users/attachments/20101216/9d99e641/attachment.html>

More information about the users mailing list