Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Non-destructive array processing

by runrig (Abbot)
on Jan 20, 2003 at 23:34 UTC ( #228523=note: print w/replies, xml ) Need Help??


in reply to Non-destructive array processing

Nice trick. I like it as a sort of answer to LISP-like linked lists without having to resort to 2-element array references:
my @array = qw(a b c d); my $r = sub { \@_ }->(@array); my $a = cdr($r); print "arr: @array\n"; print "a: @$a\n"; print "r: @$r\n"; $array[2]="hello"; print "arr: @array\n"; print "a: @$a\n"; print "r: @$r\n"; sub cdr { my $r = shift; my $a = sub { \@_ }->(@$r); shift @$a; $a; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://228523]
help
Chatterbox?
[Yaerox]: Is there any recommended perl-module for an CSPRNG in 2016?
[ambrus]: Yaerox: good question, I don't know

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (6)
As of 2016-12-06 10:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (101 votes). Check out past polls.