1. Re: No Comments on "$2" or $4" etc.?

----- Original Message -----
From: "Al Getz" <Xaxo at aol.com>
>
> Any comments about the notation presented for the
> last element in a sequence and references FROM
> that element too?
>
> s={1,2,3,4,5,6,7}
> s=s[1..$3]  --s={1,2,3}

s would be {1,2,3,4}

And I kinda do like the idea of a number directly after $ meaning "the
element that many back from the last element", although it might be somewhat
confusing to those encountering it for the first time :) .

>
> s=s[2$4] --s={1,2,4,5,6,7} --remove elements between 2 and 4

Here I think I prefer the idea of a different token, say, "~", to mean
"remove the elements between x & y":
s=s[2~4] --s={1,2,4,5,6,7} --remove elements between 2 and 4

as "~" gives a sortof indication of "take away" (~ looks a little like a
sloppy minus sign), and since it's different, your mind doesn't have to stop
& wonder "does that '$' mean 'end', or something else"?  Less potential for
confusion, I think.  (Someone else previously suggested "~", I think?)

Dan Moyer

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu