Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
roast/S03-sequence/limit-arity-2-or-more.t
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
35 lines (24 sloc)
1.06 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use v6; | |
use Test; | |
# L<S03/List infix precedence/"the sequence operator"> | |
plan 8; | |
# sequence with a limit function of arity 2 | |
is (8,*/2 ... (*-*).abs < 2).join(', '), '8, 4, 2, 1', 'arity-2 convergence limit'; | |
is (8,*/2 ...^ (*-*).abs < 2).join(', '), '8, 4, 2', 'arity-2 excluded convergence limit'; | |
# sequence with a limit function of arity 3 | |
{ | |
my $i = -5; | |
my @seq = { ++$i; $i**3-9*$i } ... { ($^a-$^b) > ($^b-$^c) }; | |
is @seq.join(', '), '-28, 0, 10, 8, 0, -8, -10', 'arity-3 curvature limit'; | |
} | |
{ | |
my $i = -5; | |
my @seq = { ++$i; $i**3-9*$i } ...^ { ($^a-$^b) > ($^b-$^c) }; | |
is @seq.join(', '), '-28, 0, 10, 8, 0, -8', 'arity-3 excluded curvature limit'; | |
} | |
is (2, 1, 0.5 ... (*-*).abs < 2).join(', '), '2, 1', 'ASAP arity-2 convergence limit'; | |
is (2, 1, 0.5 ...^ (*-*).abs < 2).join(', '), '2', 'ASAP arity-2 excluded convergence limit'; | |
# limit function that accepts any number of args | |
is (1 ... { @_ eq "1 2 3" }).join(', '), '1, 2, 3', 'arity-Inf limit'; | |
is (1 ...^ { @_ eq "1 2 3" }).join(', '), '1, 2', 'arity-Inf excluded limit'; | |
# vim: expandtab shiftwidth=4 |