6. Palindrome
In this problem, you’re asked to enter some APL code, including an APL symbol and the data (text or numbers) given to it. Your code will be tested by the APL Challenge system to check whether it gives the correct answer and uses the methods described below.
In APL, yes/no questions are answered with 1 for yes
and 0 for no
.
≡ (Match) reports whether whatever is on its left matches whatever is on its right. For example, 'YOU' ≡ 'YOU' gives 1. However, 'I' 'LIKE' 'YOU' ≡ 'I' 'LOVE' 'YOU' gives 0, because we don’t look at each word separately, only at the whole list of texts.
To look at each word separately, remember ¨ from problem 5; you can see that 'I' 'LIKE' 'YOU' ≡¨ 'I' 'LOVE' 'YOU' gives 1 0 1, because:
1: yes,'I'matches'I'0: no,'LIKE'does not match'LOVE'1: yes,'YOU'matches'YOU'
Using ≡ and ⌽ (from problem 5), check whether 'APL' is a palindrome (a word that stays the same when read backwards). The answer should be 0 because 'APL' isn’t a palindrome.