Singly-linked list/Traversal: Difference between revisions
→{{header|Raku}}: Fix up internal link
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
Thundergnat (talk | contribs) (→{{header|Raku}}: Fix up internal link) |
||
Line 1,442:
===With <tt>Pair</tt>===
Built-in list processing in
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
if anyone really cared to...
Line 1,482:
===With custom type===
Extending <tt>class Cell</tt> from [[Singly-linked_list/Element_definition#
<lang perl6> method Seq {
|