Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement list-ops #715

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implement reverse
m-dango committed Apr 13, 2024
commit 91f8e57b9d5a0f71ea60417baf3d053985d93469
25 changes: 24 additions & 1 deletion exercises/practice/list-ops/.meta/template-data.yaml
Original file line number Diff line number Diff line change
@@ -73,7 +73,30 @@ properties:

reverse:
test: |-
'flunk;'
sprintf(q:to/END/,
cmp-ok(
reverse-list( %s ),
"eqv",
%s,
%s,
);
END
(
%case<input><list>.map({
when Positional {
.map(&?BLOCK).List;
}
default {$_}
}).List,
%case<expected>.map({
when Positional {
.map(&?BLOCK).List;
}
default {$_}
}).List,
%case<description>,
).map(*.raku)
);

unit: module

21 changes: 18 additions & 3 deletions exercises/practice/list-ops/t/list-ops.rakutest
Original file line number Diff line number Diff line change
@@ -96,10 +96,25 @@ flunk; # case: e1c64db7-9253-4a3d-a7c4-5273b9e2a1bd

flunk; # case: 8066003b-f2ff-437e-9103-66e6df474844

flunk; # case: 94231515-050e-4841-943d-d4488ab4ee30
cmp-ok( # begin: 94231515-050e-4841-943d-d4488ab4ee30
reverse-list( () ),
"eqv",
(),
"reverse the elements of the list: empty list",
); # end: 94231515-050e-4841-943d-d4488ab4ee30

flunk; # case: fcc03d1e-42e0-4712-b689-d54ad761f360
cmp-ok( # begin: fcc03d1e-42e0-4712-b689-d54ad761f360
reverse-list( (1, 3, 5, 7) ),
"eqv",
(7, 5, 3, 1),
"reverse the elements of the list: non-empty list",
); # end: fcc03d1e-42e0-4712-b689-d54ad761f360

flunk; # case: 40872990-b5b8-4cb8-9085-d91fc0d05d26
cmp-ok( # begin: 40872990-b5b8-4cb8-9085-d91fc0d05d26
reverse-list( ((1, 2), (3,), (), (4, 5, 6)) ),
"eqv",
((4, 5, 6), (), (3,), (1, 2)),
"reverse the elements of the list: list of lists is not flattened",
); # end: 40872990-b5b8-4cb8-9085-d91fc0d05d26

done-testing;