Help language development. Donate to The Perl Foundation

sublist zef:yabobay last updated on 2023-01-08



a sublist is when one list is found verbatim inside another list.


determines whether a list is a sublist of another. if it can, it returns the location where it was found. otherwise, returns Nil.

use sublist;
say sublist::index(<d e f>, <a b c d e f g>); # should print 3



finds all sublist indexes and returns a list of them. returns Nil if none are found.

use sublist;
# ↓ should print 3 and 7
.say for sublist::indices(<d e f>, <a b c d e f and d e f g>);