in reply to When you first encountered Perl, which feature amazed you the most?
For example, let @f and @g contain permutations of the numbers 0..$#f. Then the product (composition) of these permutations can be obtained in one step as @f[@g].
It is also easy to obtain the inverse permutation
(swap indices and values):
@h[@f] = 0..$#f
(if there is no need to keep the source permutation,
then @f itself can be used instead of @h).
I've always wanted to have in a programming language the ability to do something like this:
($x += 2) *= 3
|
---|