Jump to content

Singly-linked list/Traversal: Difference between revisions

→‎{{header|Raku}}: Fix up internal link
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(→‎{{header|Raku}}: Fix up internal link)
Line 1,442:
===With <tt>Pair</tt>===
 
Built-in list processing in PerlRaku is not specifically based on singly-linked lists,
but works at a higher abstraction level that encapsulates such implementation choices. Nonetheless, it's trivial to use the <tt>Pair</tt> type to build what is essentially a Lisp-style cons list, and in fact, the <tt>=></tt> pair constructor is right associative for precisely that reason.
We traverse such a list here using a 3-part loop:
Line 1,457:
5
6</pre>
It would be pretty easy to make such lists iterable as normal PerlRaku lists,
if anyone really cared to...
 
Line 1,482:
===With custom type===
 
Extending <tt>class Cell</tt> from [[Singly-linked_list/Element_definition#Perl_6Raku]]:
 
<lang perl6> method Seq {
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.