- Subject: Re: [slang-users] Range array docs
- From: Duke Normandin <dukeofperl@xxxxxxxxxxx>
- Date: Wed, 21 Nov 2012 09:49:59 -0700
On Wed, 21 Nov 2012 07:08:35 +0100
Manfred Hanke <Manfred.Hanke@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
> 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].
Hi Manfred ....
Of course:
> "a range-array expressed in the form [a:b:#n] represents an array
> of exactly n elements running from a to b inclusive.
lol ... I should NEVER study docs late at night.
The # sign prefixes the total elements required in the array
Thanks
--
Duke
[2012 date index]
[2012 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]