Re: sleepless night & UFOs

new topic     » goto parent     » topic index » view thread      » older message » newer message

Jiri,

Assuming that indexList isn't empty and is valid for the contents of s, the
following should work:

function remap (sequence s, sequence indexList, newValue)

    integer listLen, i1

    listLen = length (indexList)
    i1 = indexList [1]

    if listLen > 1 then
        s [i1] = remap (s [i1], indexList [2..listLen], newValue)
    elsif listLen = 1 then
        s [i1] = newValue
    end if

    return s

end function

Have a safe trip...
Joe

-----Original Message-----
From:   Jiri Babor [SMTP:J.Babor at GNS.CRI.NZ]
Sent:   Monday, April 19, 1999 5:33 PM
To:     EUPHORIA at LISTSERV.MUOHIO.EDU
Subject:        sleepless night & UFOs

Sorry, Guys,

I know I should not even be here, I am supposed to be chasing
international driving licences or packing, but I hope somebody will
help me get over a nasty mental block. I need a fast function to
change an arbitrary element of a sequence:

    s = remap( s, { i1, i2, ...., iN }, newvalue)

In other words:

    s[i1][i2]...[iN] = newvalue

where s is a nested sequence of an arbitrary depth, and i1, ..., iN
are indexes of the element to be assigned the newvalue. I think it is
possible, in fact I think I once devised a recursive formula to do
exactly that for a version of my menus, but I just cannot find it. So,
please, I already had one sleepless night!


[Side note to Robert]
Since we already have a 'nan' (not-a-number) quantity, can we have a
similar, possibly even more useful 'thing' for general objects?
Something like 'null', or 'NULL' or 'Null' in some hated environments,
or 'None' in Python. 'nao' would be ok with me, but my personal
preference is for 'ufo' (undefined-f...-object).

Just one other thing: Ralf, your 'each' construct is an excellent
idea. I also think, given plenty of time, even Gabriel will eventually
like it. (Sorry, Gabriel, *any* sign of conservatism brings out the
worst in me!) jiri
________________________________________________________
NetZero - We believe in a FREE Internet.  Shouldn't you?
Get your FREE Internet Access and Email at
http://www.netzero.net/download.html

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu