9. Babushka
In this problem, you’re asked to enter your own APL function, without giving it any arguments. Your function will be checked by the APL Challenge system using several tests to see whether it is correct.
In problem 7 and problem 8, you saw that you could write your own function using APL symbols. You can also write functions that contain other functions that you have written. For example, a function that, given a letter, reshapes it into 3 copies, and then reshapes each copy into a 2-by-4 table, could be written like this:
{ {2 4⍴⍵}¨ 3⍴⍵} 'a'
┌────┬────┬────┐
│aaaa│aaaa│aaaa│
│aaaa│aaaa│aaaa│
└────┴────┴────┘
In problem 5, you saw how the ¨ operator can be used with functions that take a single argument (which is then on the right). It can also be used with a function that takes both a right argument and a left argument. In this case, it pairs up elements from the left with elements from the right:
1 2 3 ⍴¨ 'abc'
┌─┬──┬───┐
│a│bb│ccc│
└─┴──┴───┘
Using the way of selection you learnt in problem 3, write a function that takes a list of numbers on the left and a list of words on the right. It must then use the first number on the left to select a letter from the first word on the right, use the second number to select a letter from the second word, and so on:
3 2 1 {answer} 'HERE' 'BE' 'DRAGONS'
RED
3 3 1 5 {answer} 'JUST' 'EAT' 'APPLE' 'TODAY'
STAY