Help language development. Donate to The Perl Foundation

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

0adf9127a1e3590a5c999e5b9d7b569d0054db74/

sublist

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

sublist::index

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

enjoy!!!

sublist::indices

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>);