Re: Discuss changing the behaviour of append()
- Posted by jimcbrown (admin) Jun 11, 2014
- 4137 views
Derek, this case shows that there was some wrong logic in your "current code".
And that your subtle logic bug was fixed thanks to old good append() feature.
Okay, what was the wrong logic bug?
jimcbrown, see please 38.Re:...
Do you see the normal append() function call from Derek's new deep_append() function?
Sorry, I do not see...
I don't see the call to normal append() from deep_append(), but I also fail to see the logic bug.
That said, the existing code could be made to work with append like so:
-- 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 if atom(S[I[1]]) then -- append() is also making this check, why do we have to make this check twice??? S[I[1]] &= {X} -- having to make a new sequence also slows down the atom case else S[I[1]] = append(S[I[1]], X) end if 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
Look how much nicer it is when append() can do atoms too!
-- 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 S[I[1]] = append(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
[/quote]
This is the second Derek's logic bug -
You've failed to point out a single logic bug, let alone two.
and I can say nothing about his first logic bug.
Because it doesn't exist?
he just doesn't demonstrate that his wrong code,
Sophisma or paralogismos.
I don't see append() working on atoms being a sophismata. After all, append() already works with atoms as the second parameter!
If you really believe Derek's logic bugs fall into the category of sophisma, you should at least be able to articulate the "odd consequences" or ambiguous interpretation of true/false value here.