Singly-linked list/Element definition: Difference between revisions

Perl
(Perl)
Line 111:
 
Due to Forth's lack of typechecking, 'b' in the above examples does not have to be an actual cell, but can instead be the head pointer of the list.
 
==[[Perl]]==
[[Category:Perl]]
Just use an array. You can traverse and splice it any way. Linked lists are way too low level.
 
However, if all you got is an algorithm in a foreign language, you can use references to accomplish the translation.
my %node = (
data => 'say what',
next => \%foo_node,
);
$node{next} = \%bar_node; # mutable
 
==[[Pop11]]==
Anonymous user