[Thread Prev][Thread Next][Index]

Re: [ferret_users] high-to-low range for REPEAT over pseudo-variable



Ryo, Ansley—

On  4 Sep 19:57 Ryo Furue wrote:
> Maybe it would be nice if a new syntax is introduced for one of the two
> behaviors *without removing the existing syntax.*
> 
> Off the top of my head (and hence I don't think this is optimal),
> 
> repeat/i=(10, 1, -1)
>   --> i = 10, 9, 8, . . .  
> repeat/range=(10,1,-1)/name=m
>   --> m = 10, 9, 8, . . . 

This looks nice, but that means that if a user wants the REPEAT/I=10:1
Ferret magic to be followed, they have to use the old style.  I do not
know if there are actual examples of this.  Maybe one wants to REPEAT
through ocean depths and wants the direction of the vertical grid to be
followed (but I'm not sure if that is actually happening with
REPEAT/K=10:1).

Your specific syntax makes one think about /LEVELS=(0,5,1)(5,100,5)(inf)
which means some code from there could be reused and such consistency
could be useful to users as well, but then I realised that /LEVELS sets
ranges instead of counting indices; if one would allow
REPEAT/J=(0,5,1)(5,100,5) then 'J=5' is done two times.  Probably this
analogy is not your intention.

Finally, the additional syntax may be confusing in an other sense.  In
Julia, one could make a usual FOR loop:

    for i in 1:3
        println(i)
    end

or using numbers from an array:

    for i in [1, 2, 3]
        println(i)
    end

(this latter Julia syntax appears derived from Matlab/Octave).  In your
example, some may expect:

    repeat/i=(10, 1, -1)
      --> i = 10, 1, -1

I see there are a lot of differences between the two syntaxes, but they
still look intuitively the same to me (especially when set together
with the low:high:delta syntax for both Julia and Ferret).

—Marco


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement