Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Nodes count in Linked List

by LanX (Saint)
on Mar 31, 2015 at 13:16 UTC ( [id://1121985]=note: print w/replies, xml ) Need Help??


in reply to Perl linked list

MJD shows an implementation of linked lists in Higher Order Perl which looks quite convincing (though costly)

Each node is a two element array [value,tail_ref] with tail_ref being an array ref to the next node or undef.

To count length iterate through the list till you get undef.

Perl has no built in linked lists b/c arrays cover almost all use cases.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)

PS: Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1121985]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-25 07:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found