Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search

[REBOL] Re: Counting chars (was Simple things should be simpl e to do ?)

From: rsnell::webtrends::com at: 16-Nov-2000 16:15

It's really the hash that makes it easy. I have an associative array (that I call a map - much easier to type) that I use all the time. Given my map, my count routine becomes: s: "sdfsdfsdfsdfsdfsd" m: make map! [] foreach c s [ m/set c ((to-integer m/get c) + 1) ] repeat i m/length? [ print [(first at m/keys i) (first at m/vals i)] ] s 6 d 6 f 5 Almost as easy as Perl if you don't take into account the code for the map (which I have not included). If you don't have a map (associative array) in your toolbox, get one. It can make some functions a lot easier. If anyone wants I can post the source to mine but others have been posted by better Rebolers at various times. Rodney