
-----------------------------------
paulm
Sun May 03, 2009 4:16 pm

Help with linked lists
-----------------------------------
What is it you are trying to achieve?
insert a single character into my list "A,B,C,D,E" alphabetically (all pointers-> data are strings length of 1)


What is the problem you are having?
the proc just ends up deleting the test string from the list when it encounters it


Describe what you have tried to solve this problem
tried tracing it on paper, got very confused



%my type being used:
type cell :
    record
        data : string
        link : pointer to cell
    end record

% procedure in question
proc insert_cell (test : string)
    p := first
    var p2 : pointer to cell := first -> link
    var pn, temp : ^cell := nil
        loop

            put "p1= ", p -> data
            put "p2= ", p2 -> data

            if test  data then
                put "condition met: test >= p2  ... exiting"
                put "                  ", test, " 