Make a function encode-char that takes a char c as input and returns the encoded character. Then you can use (list->string (map encode-char (string->list s))) as you did in your upcase function.