Re: A better way then just "$" -- !

new topic     » topic index » view thread      » older message » newer message

On Tue, 23 Sep 2003 07:42:15 +1000, Derek Parnell
<ddparnell at bigpond.com> wrote:

>From: "Pete Lomax" <petelomax at blueyonder.co.uk>
<snip>
>> Hmm. consider the common expression:
>> s=3Ds[1..idx-1]&s[idx+1..length(s)]
<snip>
>> However, I did get to think what would be the easiest way to express
>> this common idiom and came up with:
>>=20
>> x[not idx]
>> or
>> x[not 3..5]
>>=20
>> which is a lot neater than
>> x[1..idx-1]&s[idx+1..length(x)]
>>=20
>> or even
>> x[1..2]&[6..$]
>>=20
>
>Pete, I like this idiom. And I'd support either X[not Y] or X[! Y]
x[!y] is not as Euphorian imo..
>
>The idiom is short, meaningful, and still euphoric. Well done.

In the interests of fair play, democratic voting, and all that, I
should point out that there *IS* a fair use of "not" immediately
following "[" which this change might break:

sequence x
	x=3D{"No","Yes"}
for i =3D 0 to 1 do
	printf(1,"%s\n",{x[not i+1]})
end for

.. My vote would be to let that very unusual case break, I seriously
doubt anyone has ever used this, or at least in the rare cases they
have, it should be easy enough to change (and easy to search for),
however what do other people think?

Pete
PS x[not 0] should give an index out of bounds error, imo.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu