Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

How do I handle circular lists?

by faq_monk (Initiate)
on Oct 08, 1999 at 00:20 UTC ( #614=perlfaq nodetype: print w/replies, xml ) Need Help??

Current Perl documentation can be found at perldoc.perl.org.

Here is our local, out-dated (pre-5.6) version:

Circular lists could be handled in the traditional fashion with linked lists, or you could just do something like this with an array:

    unshift(@array, pop(@array));  # the last shall be first
    push(@array, shift(@array));   # and vice versa

Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
[KurtZ]: mice?
[Discipulus]: your cat is dryarian holli
[holli]: not even remotely KurtZ. i did find feathers in the garden a few times though
[holli]: yet no body
[virtualsue]: I was called upon to remove a gnawed mouse carcass from the living room this morning
holli googles dryarian just to make sure that isn't actually thing
[holli]: I mean, you never know, right?
[shmem]: good $localtime monkses
[holli]: mmh. maybe a user handle "dry arian" is a bit unfortunate? https://www. pinterest.de/ dryarian/
[Discipulus]: exists!

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-11-21 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (301 votes). Check out past polls.

    Notices?