[Thread Prev][Thread Next][Index]
Re: recursive definitions
Jeff,
To do this you need to use string symbols. The REPEAT/K=1:20 changes
the context (which K slice) for each iteration. You cannot use K as if
it were a regular variable. It is a "pseudo variable" with special
properties.
But the following does work:
yes? let a1 = 1
yes? let a2 = 2
yes? let a3 = 3
yes? let a4 = 4
yes? repeat/l=1:4 go repeat_test
1
1.000
2
2.000
3
3.000
4
4.000
Where the contents of repeat_test.jnl are:
! repeat_test.jnl
!
define symbol num = `l`
list a($num)
! end
-- Jonathan Callahan
'Jeff Polton' wrote:
>
> Dear Ferreteers,
> I'm struggling trying to define a variable which is the sum of a
> number of others:
>
> potemp = temp1 + temp2 + temp3 + ... + temp20
>
> Ferret doesn't like recursive loops:
> REPEAT/K=1:20 (potemp = temp`K` + potemp)
>
> And there are too many data sets to be entering them each time by hand.
> Does anybody know of a way around this?
>
> Thanks in advance,
> Jeff Polton
> ________________________________________________________________________
> Dept of Meteorology,Reading University,Earley Gate,Reading. RG6 6BB
> Office tel: (0118) 9875123 4338 http://www.met.rdg.ac.uk/~swp98jap
> ------------------------------------------------------------------------
[Thread Prev][Thread Next][Index]
Dept of Commerce /
NOAA /
OAR /
PMEL /
TMAP
Contact Us | Privacy Policy | Disclaimer | Accessibility Statement