[REBOL] Re: count characters. (Was: Simple things should be simple to do ?)
From: al:bri:xtra at: 16-Nov-2000 21:26
> REBOL 
I'd write a bit more stuff in the header.
> 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
Instead of using '/local, I'd use 'function instead of 'func. This is
because it makes it clearer what are local variables. It can be easy to
mistype and put in "locale" instead. Using 'function makes locals obvious.
> count: make block! 0
> foreach char str [
> either look: find count char [
I'd use this instead:
either found? look: find count char [
This is to help make it clear what you're looking for.
> change (next look) ((second look) + 1)
> append count reduce [char 1 "^/"]
> return count
I hope that helps.