daily pastebin goal
75%
SHARE
TWEET

Untitled

a guest Oct 15th, 2018 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /home/duff/git/rakudo/src/core [nom *+$ u=]
  2. ➤ vi operators.pm
  3. /home/duff/git/rakudo/src/core [nom *+$ u=]
  4. ➤ git diff
  5. diff --cc src/core/operators.pm
  6. index f6a0eec,acffab3..0000000
  7. --- a/src/core/operators.pm
  8. +++ b/src/core/operators.pm
  9. @@@ -90,6 -90,58 +90,57 @@@ sub SEQUENCE($left, $right, :$exclude_e
  10.           ($cmp < 0) ?? { $^x.succ } !! ( $cmp > 0 ?? { $^x.pred } !! { $^x } )
  11.       }
  12.  
  13. +     my sub sequence_generator($tail) {
  14.  -        $tail.munch($tail.elems - 3) if $tail.elems > 3;
  15. +         my $a = $tail[0];
  16. +         my $b = $tail[1];
  17. +         my $c = $tail[2];
  18. +         my $generator;
  19. +         if $tail.grep({ $_ ~~ Numeric}).elems != $tail.elems {
  20. +             # non-numeric
  21. +             if $tail.elems == 1 {
  22. +                 $generator = $infinite ??  { $^x.succ } !! succpred($a cmp $endpoint);
  23. +             }
  24. +             else {
  25. +                 $generator = succpred($tail[*-2] cmp $tail[*-1]);
  26. +             }
  27. +         }
  28. +         elsif $tail.elems == 3 {
  29. +             my $ab = $b - $a;
  30. +             if $ab == $c - $b {
  31. +                 if $ab != 0 || $a ~~ Numeric && $b ~~ Numeric && $c ~~ Numeric {
  32. +                     $generator = { $^x + $ab }
  33. +                 }
  34. +                 else {
  35. +                     $generator = succpred($b cmp $c)
  36. +                 }
  37. +             }
  38. +             elsif $a != 0 && $b != 0 && $c != 0 {
  39. +                 $ab = $b / $a;
  40. +                 if $ab == $c / $b {
  41. +                     $ab = $ab.Int if $ab ~~ Rat && $ab.denominator == 1;
  42. +                     $generator = { $^x * $ab }
  43. +                 }
  44. +             }
  45. +         }
  46. +         elsif $tail.elems == 2 {
  47. +             my $ab = $b - $a;
  48. +             if $ab != 0 || $a ~~ Numeric && $b ~~ Numeric {
  49. +                 $generator = { $^x + $ab }
  50. +             }
  51. +             else {
  52. +                 $generator = succpred($a cmp $b)
  53. +             }
  54. +         }
  55. +         elsif $tail.elems == 1 {
  56. +             $generator = $a cmp $endpoint > 0 ?? { $^x.pred } !! { $^x.succ }
  57. +         }
  58. +         elsif $tail.elems == 0 {
  59. +             $generator = {()}
  60. +         }
  61. +         return $generator;
  62. +     }
  63. +
  64. +
  65.       (GATHER({
  66. /home/duff/git/rakudo/src/core [nom *+$ u=]
  67. ➤ vi operators.pm
  68. /home/duff/git/rakudo/src/core [nom *+$ u=]
  69. ➤ git diff
  70. diff --cc src/core/operators.pm
  71. index f6a0eec,acffab3..0000000
  72. --- a/src/core/operators.pm
  73. +++ b/src/core/operators.pm
  74. /home/duff/git/rakudo/src/core [nom *+$ u=]
  75. ➤ git st
  76. # On branch nom
  77. # Unmerged paths:
  78. #   (use "git reset HEAD <file>..." to unstage)
  79. #   (use "git add/rm <file>..." as appropriate to mark resolution)
  80. #
  81. #   both modified:      operators.pm
  82. #
  83. # Untracked files:
  84. #   (use "git add <file>..." to include in what will be committed)
  85. #
  86. #   ../../foo.t
  87. no changes added to commit (use "git add" and/or "git commit -a")
  88. /home/duff/git/rakudo/src/core [nom *+$ u=]
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