Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slip documentation bug ??? [ RAKU ]

In raku documentation for class Slip (https://docs.raku.org/type/Slip) and also in "Lists, sequences, and arrays" documentation (slips section: https://docs.raku.org/language/list), it is stated that "slip", "Slip (method)" and "| (prefix)" can be used to create slips but they behave slightly "different".

The thing is that I've tried to confirm the above statement but with disappointing results.

I run the following tests to find out the differences:

my $l = (1, 2, 3);

say (0, slip($l, 4)).perl;
say (0, ($l, 4).Slip).perl;
say (0, |($l, 4)).perl;

say '------------------------------';

say (slip($l, 4)).perl;
say (($l, 4).Slip).perl;
say (|($l, 4)).perl;

say '------------------------------';

say (0, slip($l)).perl;
say (0, ($l).Slip).perl;
say (0, |($l)).perl;

say '------------------------------';

say (0, slip $l).perl;
say (0, $l.Slip).perl;
say (0, |$l).perl;

say '------------------------------';

say (slip $l).perl;
say ($l.Slip).perl;
say (|$l).perl;

and the results are the same for all three of them:

(0, $(1, 2, 3), 4)
(0, $(1, 2, 3), 4)
(0, $(1, 2, 3), 4)
------------------------------
slip($(1, 2, 3), 4)
slip($(1, 2, 3), 4)
slip($(1, 2, 3), 4)
------------------------------
(0, 1, 2, 3)
(0, 1, 2, 3)
(0, 1, 2, 3)
------------------------------
(0, 1, 2, 3)
(0, 1, 2, 3)
(0, 1, 2, 3)
------------------------------
slip(1, 2, 3)
slip(1, 2, 3)
slip(1, 2, 3)

Is there a catch or is it a documentation bug?

like image 297
jakar Avatar asked Jan 14 '20 16:01

jakar


1 Answers

Just a little further down the docs you find an example of the ( a? ) difference:

Please note that prefix:<|> will also apply parameters in a slippy manner to a routine call. It does not forward a Slip to the called routine, that includes return and take.

my \l = gather for 1..10 -> $a, $b { take |($a, $b) }; say l.perl;
# OUTPUT: «((1, 2), (3, 4), (5, 6), (7, 8), (9, 10)).Seq
my \m= gather for 1..10 -> $a, $b { take ($a, $b).Slip }; say m.perl;
# OUTPUT: «(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).Seq
like image 59
Holli Avatar answered Oct 23 '22 23:10

Holli