{"atom":"regression/conformance-list-adverbs","family":"regression","slug":"conformance-list-adverbs","header":{"atom":"regression/conformance-list-adverbs","kind":"whole-program — a minimal repro, not yet reduced to an atom","source":"curated"},"axes":null,"cols":null,"engines":["rakudo-2026.07","rakupp-3.14.0"],"kinds":["ref","pp"],"defFrom":"rakupp:t/regression/conformance-list-adverbs.raku","counts":{"a":1,"f":0,"d":0,"c":0,"r":0,"n":0},"files":["atoms/regression/conformance-list-adverbs.grid"],"records":[["0001","","# Regression: the adverbial forms of the list routines, and the container each\n# one answers in.\n#   * `.rotor(2, 3)` CYCLES its size arguments (2, 3, 2, 3, …); only the last one\n#     used to take effect. A trailing window that is complete is still emitted.\n#   * `.min`/`.max` take `:by(&code)` (the named spelling of the mapper) and\n#     `:k`/`:v`/`:kv`/`:p`, which answer EVERY position attaining the extremum.\n#     The SUB forms delegate to the method, so a lone Positional/Associative\n#     argument is the list and several arguments are NOT flattened.\n#   * `.first` grew `:v`/`:kv`/`:p` beside `:k`, and takes a Regex matcher —\n#     `applyArith`'s `~~` does not know regexes, so it needs the engine directly.\n#   * `.sort`/`.reverse`/`.unique`/`.squish`/`.head`/`.tail`/`.skip`/`.rotor` are\n#     Seq in Rakudo, including their sub forms.\n#   * `deepmap`/`duckmap` answer in the INVOCANT's container; `nodemap` is always\n#     a List. All three are list operators, so they take a bare first argument.\n#   * `&infix:«OP»` is the guillemet spelling of `&infix:<OP>`; `<=>` survives the\n#     double-angle strip that `infix:<<∈>>` needs.\n#   * a `Rat` parameter REJECTS an Int (`3 ~~ Rat` is False), which is what makes\n#     `duckmap -> Rat $_ {…}` descend past the Ints.\n# Contract: exit 0 + last line PASS.\nmy @fail;\nsub check($got, $want, $what) { @fail.push(\"$what: got $got want $want\") unless $got eq $want }\n\n# .rotor cycles its specs\ncheck(<a b c d e f g>.rotor(2, 3).gist, '((a b) (c d e) (f g))', 'rotor-cycles-sizes');\ncheck((1..10).rotor(3, 2).gist, '((1 2 3) (4 5) (6 7 8) (9 10))', 'rotor-cycles-over-a-range');\ncheck(<a b c d e f g>.rotor(1, 2 => -1).gist,\n      '((a) (b c) (c) (d e) (e) (f g) (g))', 'rotor-cycles-sizes-and-gaps');\n# the single-spec forms are unchanged\ncheck(<a b c d e f g>.rotor(3).gist,        '((a b c) (d e f))',           'rotor-plain');\ncheck(<a b c d e f g>.rotor(2 => 1).gist,   '((a b) (d e))',               'rotor-with-a-gap');\ncheck(<a b c d e f g>.rotor(3 => -1).gist,  '((a b c) (c d e) (e f g))',   'rotor-overlapping');\ncheck(<a b c d e f g>.rotor(2 => 1, :partial).gist, '((a b) (d e) (g))',   'rotor-partial');\ncheck(<a b c>.batch(2).gist,                '((a b) (c))',                 'batch-keeps-the-short-tail');\n\n# .min/.max adverbs — every position attaining the extremum\ncheck(<a b c a>.min(:k).gist,  '(0 3)',              'min-k');\ncheck(<a b c a>.min(:v).gist,  '(a a)',              'min-v');\ncheck(<a b c a>.min(:kv).gist, '(0 a 3 a)',          'min-kv');\ncheck(<a b c a>.min(:p).gist,  '(0 => a 3 => a)',    'min-p');\ncheck(<a b c c>.max(:k).gist,  '(2 3)',              'max-k');\ncheck(<a b c c>.max(:p).gist,  '(2 => c 3 => c)',    'max-p');\ncheck((1, 7, 3).min,           '1',                  'min-plain');\ncheck((1, 7, 3).min({ 1 / $_ }), '7',                'min-with-a-mapper');\ncheck(min(1, 7, 3, :by({ 1 / $_ })), '7',            'min-by-is-the-named-mapper');\ncheck(max(1, 7, 3, :by({ 1 / $_ })), '1',            'max-by');\ncheck(min(%(a => 3, b => 7)).gist, 'a => 3',         'min-of-a-hash-is-a-pair');\ncheck(min((1, 2), (3, 4)).gist,    '(1 2)',          'min-does-not-flatten-its-arguments');\ncheck(min(1, 7, 3),                '1',              'min-sub-plain');\n\n# .first — the answer forms, and a Regex matcher\ncheck(<a b c d>.first(*.uc eq 'C'),      'c',       'first-plain');\ncheck(<a b c d>.first(*.uc eq 'C', :k),  '2',       'first-k');\ncheck(<a b c d>.first(*.uc eq 'C', :v),  'c',       'first-v');\ncheck(<a b c d>.first(*.uc eq 'C', :kv).gist, '(2 c)',   'first-kv');\ncheck(<a b c d>.first(*.uc eq 'C', :p).gist,  '2 => c',  'first-p');\ncheck((3..33).first(/\\d\\d/),             '10',      'first-with-a-regex');\ncheck(<a bb>.first(/\\w\\w/),              'bb',      'first-regex-over-a-list');\ncheck((1..20).first(* %% 7, :end),       '14',      'first-end');\n\n# containers\ncheck(<b c a>.sort.^name,      'Seq', 'sort-is-a-seq');\ncheck((9, 8).reverse.^name,    'Seq', 'reverse-is-a-seq');\ncheck([9, 8].reverse.^name,    'Seq', 'reverse-of-an-array-is-a-seq-too');\ncheck((1, 1).unique.^name,     'Seq', 'unique-is-a-seq');\ncheck((1, 2).head(1).^name,    'Seq', 'head-is-a-seq');\ncheck((sort <b a>).^name,      'Seq', 'the-sort-sub-is-a-seq');\ncheck((reverse 1, 2).^name,    'Seq', 'the-reverse-sub-is-a-seq');\ncheck(<b c a>.sort.join,       'abc', 'sort-still-sorts');\ncheck((9, 8, 7).reverse.gist,  '(7 8 9)', 'reverse-still-reverses');\n\n# deepmap/duckmap keep the invocant's container; nodemap is a List\ncheck([[1, 2], [3]].deepmap(* + 1).^name, 'Array', 'deepmap-keeps-an-array');\ncheck(((1, 2), (3)).deepmap(* + 1).^name, 'List',  'deepmap-keeps-a-list');\ncheck([1, 2].nodemap(* + 1).^name,        'List',  'nodemap-is-always-a-list');\ncheck([1, 2].duckmap(* + 1).^name,        'Array', 'duckmap-keeps-an-array');\n# … and they are list operators, so the first argument needs no parentheses\ncheck((deepmap * + 1, [[1, 2, 3], [[4, 5], 6, 7]]).gist,\n      '[[2 3 4] [[5 6] 7 8]]', 'deepmap-as-a-listop');\ncheck((duckmap *², [[1, 2, 3], [[4, 5], 6, 7]]).gist, '[9 9]', 'duckmap-as-a-listop');\n# a Rat parameter rejects an Int, so duckmap descends past the whole numbers\ncheck((duckmap -> Rat $_ { $_² }, [[1, 2, 3], [[4, 5], 6.1, 7.2]]).gist,\n      '[[1 2 3] [[4 5] 37.21 51.84]]', 'duckmap-quacks-on-the-rats-only');\ncheck((try sub (Rat $x) { $x }(3)).defined, 'False', 'an-int-does-not-bind-a-rat-param');\ncheck(sub (Rat $x) { $x }(3.5),             '3.5',   'a-rat-still-binds');\ncheck(sub (Real $x) { $x }(3),              '3',     'an-int-still-binds-real');\n\n# operator names\ncheck(&infix:«+»(1, 2),               '3',    'guillemet-operator-name');\ncheck(&infix:«<=>»(1, 2).gist,        'Less', 'guillemet-name-of-an-angle-shaped-op');\ncheck(&[<=>](1, 2).gist,              'Less', 'bracket-form-of-the-same-op');\ncheck('231'.comb.sort(&infix:«<=>»).join, '123', 'the-op-value-works-as-a-comparator');\ncheck(&infix:<+>(1, 2),               '3',    'the-plain-angle-name-still-works');\n\n# odds and ends the documentation demonstrates\ncheck(Whatever.elems, '1',  'elems-of-a-type-object');\ncheck(Any.elems,      '1',  'elems-of-any');\ncheck(Int.elems,      '1',  'elems-of-int');\ncheck((42).elems,     '1',  'elems-of-a-scalar-is-unchanged');\ncheck('food'.serial,  'food', 'serial-is-the-identity');\ncheck((a => 1, 'b', 'c').pairup.raku, '(:a(1), :b(\"c\")).Seq', 'pairup-a-pair-stands-alone');\ncheck((1, 2, 3, 4).pairup.raku,       '(1 => 2, 3 => 4).Seq', 'pairup-reads-pairwise');\ncheck(((1, 2), (3), %(:42a)).flat.gist, '(1 2 3 a => 42)', 'flat-opens-a-hash-into-pairs');\ncheck((1, 2).Capture.gist,            '\\(1, 2)',      'list-capture');\ncheck((a => 1, 2).Capture.raku,       '\\(2, :a(1))',  'list-capture-sorts-nameds-last');\ncheck(\\(1, :a(2)).gist,               '\\(1, :a(2))',  'a-capture-gists-as-its-literal');\n\nif @fail { note \"FAILED: @fail.join('; ')\"; say 'FAIL' } else { say 'PASS' }","output PASS","a",["PASS","PASS"],0,[["budget","20s"]]]]}