On Thu, 28 Feb 2019, Sven Schreiber wrote:
Am 27.02.2019 um 20:13 schrieb Allin Cottrell:
> for series, lists, matrices and arrays. We could accept a negative value
> for start or stop as meaning count back from the end,
> We already have apparatus to parse such a specification for ranges of
> matrix rows/columns, which could probably be reused without too much
> difficulty.
Could you clarify the negative index values? In the changelog for 2016d I
read:
"Matrix manipulation syntax: allow use of negative indices to
drop specified rows/columns"
So are negative indices now supposed to have a different meaning?
As Jack says, the original meaning of a negative index in a matrix
"slice" (i.e. drop the specified row or column) is still there, but I
thought the alternative meaning of "count from the end" was called for
in the new print-range specification.
This is now in place for series, lists, matrices, arrays and strings
(in which case the range refers to lines of text. Some examples below.
You can give a predefined scalar in place of a numeric value for start
and stop, but at present you can't compute a value within the option
string.
<hansl>
open data4-1
print 1 2 3 --byobs --range=2:8
print sqft --byobs --range=-5:
matrix m = mnormal(10,2) ~ seq(1,10)'
print m --range=3:7
strings S = array(15)
loop i=1..nelem(S) -q
S[i] = sprintf("string%d", i)
endloop
print S --range=1: # maybe accept "all"?
string s =
readfile("http://gretl.sourceforge.net/")
print s --range=128:130
</hansl>
BTW the prior effect of "print" for arrays was to print the elements
in sequence if the array had 10 or fewer elements -- and just its type
and size otherwise. OK to scrap that now? (I mean, just print size and
type by default, and rely on --range if the elements are wanted.)
Allin