Without much ado, today’s problem - Put it in Reverse
The find function X⍷Y identifies the beginnings of occurrences of array X in array Y.
In this problem, you’re asked to return a result that identifies the endings of occurrences of array X in array Y. To keep things simple, X and Y will be at most rank 1, meaning they’ll either be vectors or scalars.
Write a function that:
'abra' findEnd 'abracadabra'
0 0 0 1 0 0 0 0 0 0 1
'issi' findEnd 'Mississippi'
0 0 0 0 1 0 0 1 0 0 0
'bb' findEnd 'bbb bbb'
0 1 1 0 0 1 1
(,42) findEnd 42
0
42 findEnd 42
1
(,42) findEnd ,42
1
'are' 'aquatic' findEnd 'ducks' 'are' 'aquatic' 'avians'
0 0 1 0
⌽⍺
in ⌽⍵
Taking example 'abra' {⌽(⌽⍺)⍷⌽⍵} 'abracadabra'
'abra' ⍷ 'abracadabra'
, we get 1 0 0 0 0 0 0 1 0 0 0
as 'abra
matches twice at index 1 and 81 0 0 0 0 0 0 1 0 0 0
0 0 0 1 0 0 0 0 0 0 1