7. More Palindromes
Note: 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.
You can create your own function by putting an expression in curly brackets ( {…} ). For example, the expression 2+3 becomes the function {2+3}. Your function can take a right argument by using ⍵ (omega, the right-most letter of the Greek alphabet); any ⍵ is replaced by the data to the right of the closing curly bracket ( } ).
For example, a function that multiplies its right argument by two could be written {2×⍵}. Then:
{2×⍵} 5gives10{2×⍵} 7gives14
When we write APL code and its result together, we write the APL code with six spaces on its left, and its result below it. For example:
2+2
4
Remember from problem 4 that the right argument of each function is the result of all the code to its right. This means that a function that subtracts one from its argument and then multiplies it by two, could be written {2×⍵-1}.
Using what you learnt in problem 6, write a function that checks whether its argument is a palindrome (a word that stays the same when read backwards). For example:
{answer} 'RACECAR'
1
{answer} 'MEDIUM'
0
{answer} 'CIVIC'
1