- Subject: Re: [slang-users] Range array docs
- From: Manfred Hanke <Manfred.Hanke@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 21 Nov 2012 07:08:35 +0100
Hi Duke,
> I [...] couldn't find any mention of using the # prefix.
Two paragraphs above the example you're citing,
http://www.jedsoft.org/slang/doc/html/slang-11.html says: "a range-array
expressed in the form [a:b:#n] represents an array of exactly n elements
running from a to b inclusive. It is equivalent to a+[0:n-1]*(b-a)/(n-1)."
That is,
[0 : 100 : 25]
is an array from exactly 0 to (in this case) 100, in steps of exactly 25
whereas
[0 : 100 : #5]
is an array from exactly 0 to exactly 100, with exactly 5 elements.
Note that the array
> [first-value : last-value : increment]
may or may not include `last-value'. (See the docs for the details.)
For example, [0 : 100 : 25] == [0 : 123 : 25], because 100 + 25 > 123.
Therefore, one has to be especially careful with non-integer valued
range arrays like [0 : 1 : .25] -- which is probably [0., .25, .5, .75].
Cheers,
Manfred
> The docs say:
>
> --------------------------------8<--------------------------
> The syntax for the most general form of range array is given by
> [first-value : last-value : increment]
>
> --------------------------------8<--------------------------
>
> The examples show e.g.:
>
> [0:1:#5] ==> [0.0, 0.25, 0.50, 0.75, 1.0]
> [0:-1:#3] ==> [0.0, -0.5, -1.0]
>
> The increment must be preceded by a # sign, I take it. I was looking
> for confirmation of this point, but couldn't find any mention of
> using the # prefix.
>
> Perhaps the syntax explanation above, could be adjusted to reflect
> the need for the # prefix?? Just a suggestion ...
>
> --
> Duke
[2012 date index]
[2012 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]