[Thread Prev][Thread Next][Index]
Re: [ferret_users] high-to-low range for REPEAT over pseudo-variable
Hi Marco,
I think you've got it right.
REPEAT/i=1:2 is going to repeat over the x-axis context of the
variables in the repeat loop. And it turns out that Ferret context
handling does just what you're showing in your examples. Here are some
more,
yes? let var = xsequence({2,4,6,8})
yes? list/i=2:1 var
VARIABLE : XSEQUENCE({2,4,6,8})
SUBSET : 2 points (X)
1 / 1: 2.000
2 / 2: 4.000
! You can't do this:
yes? list/i=4:2:-1 var
**ERROR: invalid command: delta non-positive on X axis of EX#1
! but repeat does allow a negative increment.
yes? repeat/i=4:2:-1 (list/nohead var)
!-> REPEAT: I=4
8.000
!-> REPEAT: I=3
6.000
!-> REPEAT: I=2
4.000
The REPEAT/RANGE syntax is set up to not interact with the context of
the variables, so as you thought it's interpreting a loop range of
/i=0:1 to not have any range. This seems like the right behavior, if a
little unexpected. I'll add a note in the documentation about it.
Ansley
On 9/3/2020 7:01 AM, Marco van Hulten wrote:
Hi all,
When I use a negative/empty repeat range, nothing is done (as is with
FOR loops in other programming languages), but if a pseudo-variable is
used, it happily counts (starting from the lowest number):
yes? repeat/range=1:0/name=ii ( say JA )
yes? repeat/i=1:0 ( say JA )
JA
JA
yes? let lolo = XSequence({ 1, 9 })
yes? repeat/i=1:2 ( list/noh lolo )
1.000
9.000
yes? repeat/i=2:1 ( list/noh lolo )
1.000
9.000
yes? repeat/i=2:1:-1 ( list/noh lolo )
9.000
1.000
Why is this?
Maybe the abstract i axis does not have a direction and Ferret is
making a best guess (assuming you don't want an empty range)?
—Marco
--
Ansley Manke
Science Data Integration Group
NOAA Pacific Marine Environmental Laboratory
7600 Sand Point Way NE
Seattle WA 98115
I am currently teleworking and am available Tue-Wed-Thu.
[Thread Prev][Thread Next][Index]