an example of coding general structural recursion for lists (thanks to @dkrustev for idea)