From bafba00fcacca91cd8a8f2c47c590a56ec9cce11 Mon Sep 17 00:00:00 2001 From: Elizabeth Mattijsen Date: Fri, 31 May 2024 12:46:46 +0200 Subject: [PATCH] Clarify the status of "pairup" And add tests --- README.md | 5 +++++ doc/ParaSeq.rakudoc | 7 +++++++ lib/ParaSeq.rakumod | 2 +- t/39-pairup.rakutest | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 t/39-pairup.rakutest diff --git a/README.md b/README.md index 94b4f6b..b7d866e 100644 --- a/README.md +++ b/README.md @@ -277,6 +277,11 @@ pairs **Status**: an optimized version of the [`.pairs`](https://docs.raku.org/type/List#routine_pairs) method has been implemented. +pairup +------ + +**Status**: the nature of the [`pairup`](https://docs.raku.org/type/Any#method_pairup) method basically makes it impossible to hyper. Therefore, **no** specific hypering logic has been added for this method. + permutations ------------ diff --git a/doc/ParaSeq.rakudoc b/doc/ParaSeq.rakudoc index 9f7eee2..0ab38e5 100644 --- a/doc/ParaSeq.rakudoc +++ b/doc/ParaSeq.rakudoc @@ -343,6 +343,13 @@ B: an optimized version of the L|https://docs.raku.org/type/List#routine_pairs> method has been implemented. +=head2 pairup + +B: the nature of the +L|https://docs.raku.org/type/Any#method_pairup> method +basically makes it impossible to hyper. Therefore, B specific +hypering logic has been added for this method. + =head2 permutations L|https://docs.raku.org/type/List#routine_permutations> diff --git a/lib/ParaSeq.rakumod b/lib/ParaSeq.rakumod index 7c930df..a336c12 100644 --- a/lib/ParaSeq.rakumod +++ b/lib/ParaSeq.rakumod @@ -1518,7 +1518,7 @@ class ParaSeq does Sequence { } multi method pairup(ParaSeq:D:) { - self!pass-the-chain: self.Seq.pairup.iterator + self!pass-the-chain: self.List.pairup.iterator } proto method permutations(|) {*} diff --git a/t/39-pairup.rakutest b/t/39-pairup.rakutest new file mode 100644 index 0000000..13efe67 --- /dev/null +++ b/t/39-pairup.rakutest @@ -0,0 +1,17 @@ +use Test; +use ParaSeq; + +plan 4; + +my constant $elems = 200000; +my constant @list = (^$elems).List; +my constant @pairedup = @list.pairup.List; +my constant $batch = 16; + +for 1, ParaSeq.default-degree { + my $seq := @list.&hyperize($batch, $_).pairup; + isa-ok $seq, $_ == 1 ?? Seq !! ParaSeq; + is-deeply $seq.List, @pairedup, ".pairup with degree = $_"; +} + +# vim: expandtab shiftwidth=4