Generalized Array Handlers: A Starting Point?

Rob Cozens rcozens at pon.net
Mon Jul 12 11:44:52 EDT 2004


Andre, Troy, et al:

These are untested, and recursion is not my strong suit; but perhaps 
you can use them as a starting point?

function getElement @theArray,theCoordinates,theDelimiters
    if the number of lines of theCoordinates <> the number of lines of 
theDelimiters then return "Coordinate--Delimiter Mismatch"
    set the itemDelimiter to line 1 of theDelimiters
    get item (line 1 of theCoordinates) of theArray
    delete line 1 of theCoordinates
    if theCoordinates is empty then return it
    delete line 1 of theDelimiters
    return getElement (it,theCoordinates,theDelimiter)
end getElement

on putElement theElement, at theArray,theCoordinates,theDelimiters
    if the number of lines of theCoordinates <> the number of lines of 
theDelimiters then return "Coordinate--Delimiter Mismatch"
    repeat
       if the number of lines of theCoordinates = 1 then
          set the itemDelimiter to (line -1 of theDelimiters)
          put theElement into item (line -1 of theCoordinates) of theArray
          exit repeat
       end if
       delete line -1 of theDelimiters
       delete line -1 of theCoordinates
       get getElement (theArray,theCoordinates,theDelimiters)
       putElement it,theArray,theCoordinates,theDelimiters)
    end repeat
end putElement
-- 

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)


More information about the use-livecode mailing list