I’m working on an application which involves looking at words that
have macrons ( that’s the “long sound” bar over a letter ). Under
certain spellings the macrons move from macron-ized to ‘no macron’.
I tried to do this in Ruby without any help, but ultimately friends
and saner voices convinced me that given Ruby’s current state with
respect to UTF-8 i would be saved many sleepless nights by including
And boy did it help! Yay!
Nevertheless, as I’ve written modules to deal with the
aString.chars[x…y] to retrieve characters ( versus simple bytes
( which may or may not completely map to a character! )), I’ve found
myself writing simple recursive functions whose work would have been
made more simple by:
macronizedString.firstChar ( or the ‘car’ if you Lisp )
macronizedString.restOfString ( or the ‘cdr’ if you Lisp ).
Is there a reason these are not included? I don’t mean “hey get off
your butts and write these for me” , I mean it more in the sense of
“am I so dumb that I’m not using the true power of the module to do
things the easy way - versus writing painful functions”.
For example ‘lastChar’ works along the lines of
firstChar = macronizedString.chars
lastChar = macronizedString.chars[0…macronizedString.jlength-1]
restOfString = macronizedString.chars[1…99] # assuming string < 99
chars, probably not safe, surely there’s a better way?
Thanks to Ruby’s slick “extend class” I was thinking about adding
these methods in…am I doing a good thing or a foolish thing? Am I
doing it in a sapient or foolish manner?