Skip to content

Instantly share code, notes, and snippets.

@timbunce
Created October 6, 2012 21:05
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 timbunce/3846125 to your computer and use it in GitHub Desktop.
Save timbunce/3846125 to your computer and use it in GitHub Desktop.
@xyz»++ # increment all elements of @xyz
@x = @a »min« @b # @x is smallest of @a and @b
$mean = ([+] @a) / @a # calculate mean of @a
$sumsq = [+] (@x »**» 2) # sum of squares of @x
$fact = [*] 1..$n # $n factorial
sub postfix:<!> { [*] 1..$^n } # define new operator
say 5!; # 120
@odd = 1,3 ... * # odd numbers (lazy & infinite)
@fib = 1,1 ... &[+] # the entire Fibonacci sequence
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment