[REBOL] BASIC-like string functions
From: greggirwin::starband::net at: 27-Aug-2001 20:06
Ramping up on REBOL after being a BASIC/VB guy, I didn't see any words that
equate to BASIC's Left, Right, and Mid which return their respective part
(left, right, or middle) of a given string. So here's what I came up with:
left: func [s len][copy/part s len]
right: func [s len][copy at s ((length? s) - (len - 1))]
mid: func [s start len][copy/part at s start len]
right can also be written without using copy:
right: func [s len][at s ((length? s) - (len - 1))]
Given that these functions seem to work, and not just on strings of course,
I'd like to hear from some real REBOLs if I'm missing anything obvious. For
example, is there a way to do it without using copy (as in the second
version of right), or is copy the right way to go?
If I missed native words, or if this is just a horribly non-REBOL idiom, I'd
really like to hear that as well.