> -----Original Message-----
> From: Carl Read [mailto:[EMAIL PROTECTED]
> Sent: Friday, October 17, 2003 2:02 AM
> To: [EMAIL PROTECTED]
> Subject: [REBOL] Re: Cunning use of [], () & {} in R# and in future?
> Rebol versions?
> 
> 
> 
> On 17-Oct-03, Andrew Martin wrote:
> 
> > Earlier I wrote:
> >>> X[2]
> >> == "b"
> 
> > It looks like I'm solving problems which not yet exist.
> 
> But it got me thinking anyway, so would this be useful...
> 
> >> blk: ["a" "b" "c" "d" "e"]
> == ["a" "b" "c" "d" "e"]
> >> blk/[1 4 5]
> == ["a" "d" "e"]
> 


now you're talking

it even looks rebolish... add python's list notation which is nice (I must admit, and 
is missing altogether in rebol).

examples (with equivalent rebol line after): 

series[5:10] -> return a series starting at 5 ending at 10
copy/part at series 5 at series 10

series[5]    -> return element 5 
series/5  (I'd rather keep series/5 and add /[5] which returns a block with only the 
fifth element in it

series[:10]  -> return everything up to element 10
copy/part series at series 10

series[5:]   -> return everything starting a element 5
at series 5


you can even use negative indexes to reverse the direction...

so:
series[-5:-10]
reverse at series (length? series - 10) at series (length? series - 5)


the advantage of the python notation is that it is much more unified. It is also often 
much shorter and more visual

I'm not saying scrap the current system (we needs its versatility and oppeness), just 
adding some equivalent to the python method in the way Carl just wrote it.  We'd all 
benefit from shorter, often, more redeable scripts.


I know we can write a function for it... but that adds a word in the source which 
really isn't needed if its supported in the base syntax.  Only RT can do that.


the way carl just describes it, added with added range notation does not break any 
current rebol syntax I can remember, yet it makes our lives much simpler.

What do you all think?


-MAx



-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to