Skip to content

Instantly share code, notes, and snippets.

@marcoonroad
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcoonroad/5064882c61aa94038b8d to your computer and use it in GitHub Desktop.
Save marcoonroad/5064882c61aa94038b8d to your computer and use it in GitHub Desktop.
Try something as 'perl thisScript.pl 1 2 3 4 5 6 7 8 9 10' on command-line...
use warnings;
# === Clean way: =============================== #
# use List::Util qw/ product /; #
# sub factorial { product 1 .. $_[0] } #
# print factorial 5; #
# ============================================== #
sub{print @_,"\n"}->(sub{sub{my($c,$r)=(shift,1);;
$r=$c->($r,$_)for@_;$r}->(shift,1..shift)}->(&{sub
{sub{$_[0]*$_[1]},shift}}(shift@ARGV)))while@ARGV;
# end of script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment