> Can I get a .car and a .cdr please? In my limited mind "key" and "value"
> are specific to hashes and their wimpy brother associative lists.
Sure. Roll-you-own with:
module PAIR;
method car { return .key }
method cdr { return .value }
or, if you're really serious about it:
module PAIR;
method car { return .key }
method cdr { return .value }
method AUTOVIVIFY (&default, $name) {
if ($name =~ m/^c([ad])([ad]*)r$/) {
my $next = "c$2r";
given ($1) {
when 'a': { return sub { .car.$next() } }
when 'd': { return sub { .cdr.$next() } }
}
}
}
Damian