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

[REBOL] Re: uppercase two letters?

From: tofo:695online at: 26-Apr-2003 2:39

On Fri, Apr 25, 2003 at 05:01:43PM -0600, Gregg Irwin wrote:
> Hi Tom, > > TF> you wouldn't believe how ugly my attempts at this have been! > TF> all I want to do is squash a sentence, then make the first and third > TF> letters uppercase. > > Well, let's see, we could start by writing a function to handle the > general case, like so: > > uppercase-at: func [ > "Changes the letters at the specified positions to uppercase" > string positions [any-block!] > ] [ > foreach pos positions [ > poke string pos to char! uppercase to string! pick string pos > ] > ] > > Then use it like this: > > >> s: copy "this is a line" > == "this is a line" > >> uppercase-at replace/all s " " "" [1 3] > > Does that work for you? >
:-) You and Andrew inspired me to try again. How about this? squashit: func [line [string!]] [ trim/all lowercase line poke line 1 to-char uppercase to-string line/1 poke line 3 to-char uppercase to-string line/3 ] I've been a rebol novice for too long! Someone else commented recently on how difficult it seems to be to move beyond simple to advanced. Every script I try seems to center around "foreach" and rejoin . I can tell by reading this list that there's more to life... if my function is ok, poke is what I needed. thanks. -- signature mischievous: "heh, heh, heh" -tom