[REBOL] Re: count characters. (Was: Simple things should be simple to do ?)
From: tooki::widebay::net::au at: 16-Nov-2000 16:05
Hi Guys,
One last version. Since I believe a function should always return a value,
here is the final version (for now) of the character counting function:
REBOL []
count-char: func [
{
This function counts the number of occurrances of each character in
string str, and returns a printable block with the results.
}
str [string!]
/local count look
][
count: make block! 0
foreach char str [
either look: find count char [
change (next look) ((second look) + 1)
][
append count reduce [char 1 "^/"]
]
]
return count
]
Regards,
Bard