Grasshopper

algorithmic modeling for Rhino

how many times does a number appear in a list

Hi! Is there a simple way to know how many times does a number appear in a list and get that result as an output? Say a list that contains four times 5 or eight times 3... see JPG attached.

Thanks

Views: 1518

Attachments:

Replies to This Discussion

That's not a list, that's a single multi-line piece of text.

One approach would be to replace all occurrences of the number with a zero-length text. Then measure the length before and after, divide by the length of the text you were replacing and you have your answer.

If your data is a proper list, then you can use [Set Difference] to remove all values identical to some other value. Then again measure the length of the list before and after.

--

David Rutten

david@mcneel.com

Tirol, Austria

It is a proper list, I just unselected draw paths and draw indexes. I want to know how many times does each element of the list appear in the list. Can I do this with set difference?

Thanks!!!

The "member index" gives both a lookup index for each item in your list as well as a count of the number of unique instances for each unique index:

It works. Thanks!!!

Ah, I forgot about [Member Index] :)  That's indeed a lot easier.

--

David Rutten

david@mcneel.com

Tirol, Austria

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service