[R] linear lists, creation, insertion, deletion, traversal *someone?*

Kjetil Brinchmann Halvorsen kjetilbrinchmannhalvorsen at gmail.com
Wed Mar 1 15:39:33 CET 2006


Christian Hoffmann wrote:
> Hi,
> 
> In a second try I will ask this list to give me some useful pointers.
> 
> Linear lists, as described e.g. by N.Wirth in "Algorithms and Data
> Structures", seem not to be implemented in S/R, although in lisp we have 
> cons, car, cdr.
> 

This has been discussed on the list a (long) time ago, so you can
search the archives. I remember L Tierney opined they should be
implementes as a (S4) class.

Kjetil

> Nevertheless I want to implement an algorithm using such linear lists, 
> porting a trusted program to R (S). I need:
> 
> (from Modula/Oberon)
> 	pSC* = POINTER TO SC;
> 	SC* = RECORD	Next*: pSC; ......
> ...     END;
> 
> # generate and fill a linked list:
> VAR   p, pA, Kol: pSC;
> 	NEW( Kol);
> 	pA := Kol;
> 	while () {
> 		NEW( p );
> 		pA.Next := p;
> 		pA := p;
> 		...
> 	}
> 
> Mapping this list management to R's list() is possible, but may not be 
> so transparent. Insertions and deletions from a list may be more convoluted.
> 
> Does anybody have experience in this? I could not find any reference in
> R resources, also the Blue Book is mute here.
> 
> Thank you
> Christian




More information about the R-help mailing list