Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Inserting an element into an array after a certain element

by kelan (Deacon)
on Mar 31, 2005 at 21:24 UTC ( #443981=note: print w/replies, xml ) Need Help??


in reply to Re: Inserting an element into an array after a certain element
in thread Inserting an element into an array after a certain element

The Perl6 version is about the same:

sub insert_after_first( $elem, $new, *@data ) { return if @data.elems < 1; my $front = @data.shift; return ( $front, $new, *@data ) if $front ~~ $new; return ( $front, insert_after_first( $elem, $new, *@data ) ); }
I thought the parameter naming being specified in the declaration would help, but you still neet to shift the front element off of the data list for comparison or it gets real ugly.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (2)
As of 2022-08-14 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?