View Single Post
Old 06-05-2003, 11:54 AM   #9
enigma@zebedee
Member
 
Join Date: Mar 2003
Posts: 70
enigma@zebedee is on a distinguished road
Actually LPC does support char, just not in the way you are trying it :-p Shinji's latest example uses it - although it would be neater to use 'a' rather than the number for a (note the single quotes).

Now I sort of have an objection to this 'challenge' on principle because it makes text look like it was written by a CoOl DuDe 3lItE HaCkEr - but on the other hand it could be fun...

Hmmm...Now I like Ogma's solution - nice, clear, simple.

LPC has some fun stuff already like implode, explode, etc though which are sort of overkill for this but nice to play with.

Of course to do it as one statement there is always recursion....

convert(string str, status cap)
{
return (cap ? capitalize(str[0..0]) : lower_case(str[0..0])) + convert[str[1..], !cap);
}

Untested...so no guarantees...might do interesting things to the stack on long strings as well... ;p
enigma@zebedee is offline   Reply With Quote