Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Does perl6 have a native linked-list data type?

by moritz (Cardinal)
on Nov 17, 2010 at 17:52 UTC ( #872026=note: print w/ replies, xml ) Need Help??


in reply to Does perl6 have a native linked-list data type?

Perl 6 has a Pair type, which holds a key and a value. I think that's rather close to a cons type, which has car and cdr. You can built data structures out of them.

That said, arrays and lists are primitives, and trees can be built out of arrays, pairs or custom classes.


Comment on Re: Does perl6 have a native linked-list data type?
Re^2: Does perl6 have a native linked-list data type?
by LanX (Canon) on Nov 18, 2010 at 00:14 UTC
    And since Perl6 is supposed to have a very flexible syntax, it shouldn't be too difficult to adapt map, grep and other similar functions in an efficient way without hardcoding linked lists in C.

    Cheers Rolf

      And since Perl6 i supposed to have a very flexible syntax, it shouldn't be too difficult to adapt map, grep and other similar functions in an efficient way without hardcoding linked lists in C.

      That's correct, but I honestly don't understand the point. If you want lists, you just use the built-in lists. In Perl you'd use CONS/Pair only to build more complex data structures, like trees. And if you use that kind of flexibility, a generally overloaded map or grep isn't of much use anymore.

      I've heard there are applications where you need to often insert or remove items from the middle of a list, but somehow I've never needed it in my own code. If I did, the proper perlish way would be o provide an alternative to the Array type, which also implements the Positional role. It would be usable just like an Array, except with different performance charateristics.

        ... That's correct, but I honestly don't understand the point. If you want lists, you just use the built-in lists. ...
        The polymorphism would be useful. Sometime you don't care about the implementation - you just need an object which has some of the properties of an array (like the ability to perform map and grep on it.) In that case you can return a real array or a chain of CONS cells whichever is most convenient.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2014-12-20 23:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (99 votes), past polls