Re: Discuss changing the behaviour of append()

new topic     » goto parent     » topic index » view thread      » older message » newer message
kinzz said...

Derek, this case shows that there was some wrong logic in your "current code". So, your code was 'ugly', not your new function F() which corrected your mistake.

And that your subtle logic bug was fixed thanks to old good append() feature.

Or, maybe, you just forgot how append() works? smile

Seriously !?

No. Your assumptions about my code are once again wrong. Here is the actual function I'm writing...

-- This routine appends to an item at an arbitrary depth. 
-- Params: 
--     S   The sequence that holds the item which will be appended to. 
--     I   A list of indexes that point to the specific item in S to append to. 
--     X   The object that will be appended to the targeted item. 
 
function deep_append(sequence S, sequence I, object X) 
 
    if length(I) <= 1 then 
        if length(I) = 1 then 
            -- Using concatenation of a sequence here to get around appending to an atom. 
            S[I[1]] &= {X} 
        end if 
        return S 
    end if 
     
    integer n = I[1] 
    
    return S[1 .. n - 1] & {deep_append(S[n], I[2 .. $], X)} & S[n + 1 .. $] 
end function 

The above function works as specified, however I'd hoped for better performance.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu