Re: How to sort out the items of a list (count how many times the items appear)?

616 views
Skip to first unread message
Message has been deleted

SteveJG

unread,
Jul 15, 2015, 8:17:03 AM7/15/15
to mitappinv...@googlegroups.com
Perhaps start with the  Control block   

for each in list

Runs the blocks in the do section of for each item in the list. Use the given variable name, item, to refer to the current list item. You can change the name item to something else if you wish.


Put your IF statements there , do the counting and 'save' the results to a global variable perhaps.




To solve this "The categories are not fixed so I can't make one variable that will stored each category and add one (I would need a not fixed number of variables" you will have to experiment.  The for each item block will help the situation where the lists are of variable length.  The other control block that might help within the for each item block is the 

for each from to

Runs the blocks in the do section for each numeric value in the range starting at from and ending at to, incrementing number by the value of by each time. Use the given variable name, number to refer to the current value. You can change the name number to something else if you wish.



where, in the to puzzle piece to you place in the to slot is code   like      length of list xxxxx    where xxx is the length of the list. ...   from  1   by 1 also need to be filled.



Try some blocks.   If you run into difficulty, post what you tried and someone will probably provide some specific advice.

Regards,
Steve




Abraham Getzler

unread,
Jul 15, 2015, 4:05:23 PM7/15/15
to mitappinv...@googlegroups.com
Sort a copy of your list.

Then walk through the sorted list and count how many of each value you hit
before the value changes or the end of the list, emitting (value,count) along the way
for each value.

ABG

Reply all
Reply to author
Forward
Message has been deleted
0 new messages