[REBOL] Simple things should be simple to do ?
From: mdb:gci at: 15-Nov-2000 15:19
REBOL/View 0.10.38.3.1 2-Oct-2000
Copyright 2000 REBOL Technologies. All rights reserved.
>> str: "sdfsdfsdfsdfsdfsd"
== "sdfsdfsdfsdfsdfsd"
>> counts: copy []
== []
>> foreach char str [either none? find counts char [append counts
reduce [char 1]] [
[ x: (index? find counts char) + 1
[ y: (pick counts x) + 1
[ poke counts x y]]
== [#"s" 6 #"d" 6 #"f" 5]
>>
>> foreach [a b] counts [print [a " " b]]
s 6
d 6
f 5
Hello All,
The code above prints out for each unique character in str, the number
of times it occurs. Very simple and works just fine, but it isn't very
Rebolly. I had to do the Find twice and i don't like all the code
involved in adding 1 to the count.
Any suggestions to improve it?
TIA Mike.