2022-8: Let's Split!
Write a function that:
- takes a right argument that is a non-empty character vector or scalar.
- takes a left argument that is a non-empty character vector or scalar.
- returns a 2-element vector of character vectors in which the right argument is split immediately before the first occurence of any element in the left argument. If no left-argument element occurs in the right argument, then the split should happen after the last element of the right argument.
Hint: The take X↑Y and drop X↓Y functions, or the partitioned enclose function X⊂Y, could be helpful.
Examples:
'do' (your_function) 'Hello World' ┌────┬───────┐ │Hell│o World│ └────┴───────┘ 'KEI' (your_function) ⎕A ⍝ ⎕A is the system constant that contains the characters A-Z ┌────┬──────────────────────┐ │ABCD│EFGHIJKLMNOPQRSTUVWXYZ│ └────┴──────────────────────┘ (⌽⎕A) (your_function) ⎕A ┌┬──────────────────────────┐ ││ABCDEFGHIJKLMNOPQRSTUVWXYZ│ └┴──────────────────────────┘ ⎕D (your_function) ⎕A ⍝ ⎕D is the system constant that contains the characters 0-9 ┌──────────────────────────┬┐ │ABCDEFGHIJKLMNOPQRSTUVWXYZ││ └──────────────────────────┴┘ ⎕D (your_function) 'Q' ┌─┬┐ │Q││ └─┴┘ ⎕A (your_function) 'Q' ┌┬─┐ ││Q│ └┴─┘
your_function ←
Solutions

