Report # of times a character repeats in a word

how to get number of times character repeat in a list.

You can use the keep items from block to get all the instances of something in a list. You can then get the length of that list to find out how many instances it appeared in the list.

And, you can get a list of words from text with
[scratchblocks]
split [hello world] by (letter v)::operators reporter
//as in
[length v] of (keep items {<[ ] = [l]>@addInput::grey ring} from (split [hello] by (letter v)::operators)::list)::list
//It returns: 2
//In a custom block:
(number of times (letter) appears in (word)::operators)::control hat
report ([length v] of (keep items {<[ ] = (letter)>@addInput::grey ring} from (split (word) by (letter v)::operators)::list)::list)::control cap
[/scratchblocks]

Gang, the original question was about characters in a word. If you use untitled script pic (2) instead of split by word, then you can use list processing techniques on it.

thank you for that!
Any other solutiions from anyone?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.