Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
dntc
Newbie


Joined: 20 Jul 2002
Posts: 4
Location: China

PostPosted: Sun Sep 29, 2002 11:30 am   

help with a function
 
countlist
Syntax: %countlist(list)
count the number of times each item appears in a string list and return a database record with the items as key properties, and the count of each item as the value of the key


my english is poor,and can't understand the meaning.

Can you give me an example?
Reply with quote
Kjata
GURU


Joined: 10 Oct 2000
Posts: 4379
Location: USA

PostPosted: Sun Sep 29, 2002 3:19 pm   
 
Sure can. Lets say you have the following stringlist:
#VAR colors {red|blue|red|green|yellow|blue|orange|green|red|blue|orange}

Now, if you do:
#VAR count {%countlist(@colors)}
#SHOWDB @count

You will see:
red: 3
blue: 3
green: 2
yellow: 1
orange: 2

What %countlist did was return a record variable (basically a stringlist, but each item is a key-value pair) where the keys are the items in the strnglist, without repeating each more than one, and the values are the number of times the item appears in the stringlist.

Note: While testing, %countlist appeared to be giving incorrect results. In theory, it should work as described above.

Kjata
Reply with quote
dntc
Newbie


Joined: 20 Jul 2002
Posts: 4
Location: China

PostPosted: Mon Sep 30, 2002 10:16 am   
 
I see,thank you!
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net