wryun / es-shell

es: a shell with higher-order functions
http://wryun.github.io/es-shell/
Other
307 stars 25 forks source link

Minor variable subscripting improvements #82

Open jpco opened 8 months ago

jpco commented 8 months ago

More breaking changes -- sorry, sorry. I have two suggestions, both of which I've run into in practical use:

  1. Changing precedence of $$x(2). This was suggested in the mailing list many moons ago (http://wryun.github.io/es-shell/mail-archive/msg00617.html) and had vague support, but never got implemented.

This is the thing where, currently, $$x(2) is the same as $($x(2)), rather than the (not-actually-valid-syntax) $($x)(2). It would be nice if it were the latter, since the former is really easy to make happen.

  1. Changing "reverse" ranges to reverse the elements of the list returned.

This is an XS-ism, but one I find useful. One can easily get at the last element(s) of a list by reversing it with $x($#x ... 1) and then getting the first element(s) of the reversed list. I also think it's arguably more intuitive than the current behavior (that is, if lo > hi, then provide no results), because this correspondence is very natural:

$x(1 ... 3) <=> $x(1 2 3)
$x(2 ... 3) <=> $x(2 3)
$x(3 ... 3) <=> $x(3)
$x(4 ... 3) <=> $x(4 3)
$x(5 ... 3) <=> $x(5 4 3)