fork download
  1. #! /usr/bin/env perl6
  2.  
  3. BEGIN {
  4. my $c = $*PERL.compiler;
  5. my $v = $c.version;
  6.  
  7. my $v6c = Version.new('2015.12');
  8.  
  9. if $c.name.lc eq 'rakudo' and $v before $v6c {
  10. say "The currently installed version of Rakudo is $v.gist()";
  11. say 'which is from before the official release of Perl 6';
  12. say '';
  13. say "The earliest version of Rakudo this code should work on is $v6c.gist()";
  14. say '';
  15. say 'please go to http://p...content-available-to-author-only...6.org/downloads/';
  16. say 'or http://r...content-available-to-author-only...o.org/how-to-get-rakudo/';
  17. }
  18. }
  19.  
  20. ## ideone.com is currently using a version of
  21. ## Rakudo Perl 6 that is from more than a year before
  22. ## the official release of the Perl 6 spec tests
  23. ## so it will complain about the following line
  24. use v6.c;
  25.  
  26. ## This is vastly preffered to try and figure out
  27. ## a way to get this to work with such an ancient
  28. ## version of Rakudo
  29.  
  30. ## Until they fix this I guess you will just have
  31. ## to deal with this code not working
  32.  
  33. ## ( It is also annoying that they don't have colorized
  34. ## terminal support for the error that it produces )
  35.  
  36. use Test;
  37.  
  38. my @tests = (
  39. [1,2,3,4,5] => 0,
  40. [5,12,23,2,4,4,2,6,7] => 539,
  41. [-8,50,3,3,-123,4,17,99,13] => -1055.35694385, # -2982186493/2825761
  42. [2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2] => 256,
  43. [1,0,1,0,1,0] => 1,
  44. [-9,-8,-1] => -16,
  45. [0,-3] => -3,
  46. [-99] => -99,
  47. );
  48.  
  49. plan +@tests;
  50.  
  51. my &code = {reduce {&^b($^a,$^c)},flat @_ Z |(*+*,*-*,&[*],&[/],&[**])xx*}
  52.  
  53. for @tests -> $_ ( :key(@input), :value($expected) ) {
  54. is code(@input), $expected, .gist
  55. }
Runtime error #stdin #stdout #stderr 2.24s 201920KB
stdin
Standard input is empty
stdout
The currently installed version of Rakudo is v2014.7
which is from before the official release of Perl 6

The earliest version this should work on is v2015.12

please go to http://p...content-available-to-author-only...6.org/downloads/
or http://r...content-available-to-author-only...o.org/how-to-get-rakudo/
stderr
===SORRY!=== Error while compiling prog.pl
Confused
at prog.pl:24
------> use v6.⏏c;
    expecting any of:
        postfix
        statement end
        statement modifier
        statement modifier loop