[Thread Prev][Thread Next][Index]

[ferret_users] Re: assign value to array element [was: concatenating strings with integers]



Hi Marco,

One (quite dirty) way to use the very nice "ZF" option is to create a variable definition using recursion, that is, to force ferret to do something that's against its nature... (you must be very careful with the use of single and double quotes)


let First = xsequence({ "one", "two", "three" })
let Second= xsequence({ 1, 2, 3 })

let third_def =  "xsequence({"

repeat/i=1:`First,ret=iend` ( let third_def =  "`third_def` '`First`_`Second,zf=2`', "  )

let third_def =  "`third_def` 'last_not_used_item'})"
let third = `third_def`

list third

..... of course you can make it even dustier and use conditions to exclude or remove the last closing element.

Regards,

Paulo




On Tue, 2015-09-22 at 15:34 +0200, Marco van Hulten wrote:
Hi Ferret users,

I wanted to apply Paulo's xsequence/repeat solution on string-integer
concatenation (to another problem that I will report on in a different
post), but I found a problem.

Le 2015-09-18 Paulo a écrit:
> let First = xsequence({ "one", "two", "three" })
> let Second= xsequence({ 1, 2, 3 })
> 
> repeat/i=1:`First,ret=iend` ( let Third = "`First`_`Second,zf=2`" )

We want Third to be an array, but it will be a scalar here, having the
value of the last iteration.  How can one force Third to be an array,
and the assignment to be one to the i'th array element?

Marco



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

Privacy Policy | Disclaimer | Accessibility Statement