{ Here's another way to store strings as linked lists. In lists1.p, the string 'blue' would be stored like this: head -> b -> l -> u -> e -> nil Here, we store 'blue' like this: head -> e -> u -> l -> b -> nil Figure out how ReadString and WriteString work. Now, compare the ReadString and WriteString code here to the same routines in lists1.p. Which code do you like better? Could you write WriteString for the backwards version non-recursively? Would there be any advantage to doing so? } program backwardsStrings(input,output); type nodePtr = ^node; node = record data : char; next : nodePtr end; var message : nodePtr; procedure WriteString( str : nodePtr ); begin if str <> nil then begin WriteString( str^.next ); write( str^.data ) end end; procedure ReadString( var str : nodePtr ); var newNode : nodePtr; begin str := nil; while not eoln do begin new( newNode ); read( newNode^.data ); newNode^.next := str; str := newNode; end end; begin write( 'Type something: ' ); ReadString( message ); write( 'You typed: ' ); WriteString( message ); writeln end.