> use List::Util 'max';
> > my $length = max(scalar @csv_fields, scalar @import_fields);
>>
>>
> Given that is the Perl6 discovery day today I thought I'd offer a Perl6
> version:
>
> my $length = [max](@csv_fields.elems, @import_fields.elems);
>
>
Ohh ... in Perl6 you can add a method call to things in the language. So
"hello world" can be "hello world".say() .... which got me wondering could
we do this to a list as well? ... and it turns out you can. This will work
too:
my $length = (@csv_fields.elems, @import_fields.elems).max;
Then I wondered what I was dealing with here:
say (@a, @b).WHAT;
Parcel() - a parcel?!!
And HOW it does the things that it does ...
Then I wondered what other methods you could put on the end of a Parcel ...
so I used ^ to get a handle on the metaclass to ask for its methods.
say (@a, @b).^.methods;
which came out like a stringified list of methods I could join up.
say (@a, @b).^.methods.join("\n"); # see output below
Lot's more to discover ...
Nigel, who is excited by opening up Perl6 parcels before XMAS! ;-)
Nige
[1] Parcel methods
ACCEPTS
hash
fmt
sort
Seq
iterator
Bool
item
defined
rotate
perl
Capture
of
elems
postcircumfix:<[ ]>
list
eager
elems
Seq
Str
Int
list
Num
unpolar
sech
trim-trailing
rand
ord
truncate
sqrt
asin
atanh
cosh
cosec
succ
sign
chars
roots
ucfirst
samecase
tan
log10
cos
capitalize
bytes
fmt
flip
lc
p5chop
Numeric
asinh
acotan
chr
cotanh
acotanh
comb
floor
atan
asech
acos
round
eval
chop
tanh
split
match
exp
acosh
words
cotan
atan2
lcfirst
uc
sec
cis
log
substr
sprintf
trans
sin
pred
acosec
subst
sinh
cosech
acosech
abs
chomp
index
ceiling
asec
trim
trim-leading
kv
ACCEPTS
min
max
pick
first
minmax
does
grep
values
join
can
Numeric
elems
end
reduce
Str
keys
reverse
isa
uniq
map
classify
pairs
BUILDALL
new
Bool
say
print
defined
WALK
item
BUILD
REJECTS
clone
WHICH
perl
CREATE
Capture
PARROT
bless
WHENCE
WHERE
list
notdef
_______________________________________________
BristolBathPM mailing list
[email protected]
http://mailman.bristolbath.org/mailman/listinfo/bristolbathpm