daily pastebin goal
36%
SHARE
TWEET

[Perl 6] Using array as parameters

cwchen Nov 15th, 2017 100 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. sub add(@arr) {
  2.     my $sum = 0;
  3.    
  4.     for @arr -> $e {
  5.         $sum += $e;
  6.     }
  7.    
  8.     $sum;
  9. }
  10.  
  11. my @arr = (1, 2, 3, 4, 5);
  12. my $sum = add(@arr);
  13. $sum == 15 or die "Wrong value";
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top