3 ms·
First one (not 100% sure it's constant memory, I think perl optimises the for to avoid instantiating the (1..$n) list: It does since 5.005 - so for a good long
by adrianhoward 14y ago
First one (not 100% sure it's constant memory, I think perl optimises the for to avoid instantiating the (1..$n) list:
It does since 5.005 - so for a good long time now :-)
The reduce version (again, I'm unsure of const mem req). Comes in at ~1.4s:
This would allocate the array I'm afraid. You'd could use something liek List::Gen's reduce() to get around that.