Quick actions

cmd+k|ctrl+k

Navigation

Languages

Subarray

Snippet info

Language

Raku

Visibility

public

Author

fernando-correa

Created

2022-06-13T20:32:43.963068Z

Updated

2022-06-13T20:32:43.963068Z

my @big   = ^1000000;
my @small = 50 .. 55;

multi comp([], @) { True }
multi comp(($f, *@rest), ($ where * === $f, *@rest2)) {
    comp(@rest, @rest2)
}
multi comp($, $) { False }

sub subarray(@small, @big) {
    for 0 .. (@big - @small) {
        return True if comp @small, @big[$_..$_+@small]
    }
    False
}

say subarray @small, @big
INFO