1

Examples

Clojure

(defn palindrome? [s]
  (= (seq s) (reverse s)))

(comment
  (palindrome? "raceca")
  (palindrome? "madam")
  (palindrome? "소주만병만주소")
  ;;
  )

bash

$ read -p "Enter a string: " str; reversedStr=$(echo "$str" | rev); [ "$str" == "$reversedStr" ] && echo "Palindrome" || echo "Not Palindrome"

Enter a string: 111
Palindrome

perl one-line

$ perl -ne 'chomp; $rev = reverse $_; print($_ eq $rev ? "Palindrome" : "Not Palindrome"); print("\n");'

123
Not Palindrome
321
Not Palindrome
222
Palindrome
2242
Not Palindrome
22422
Palindrome

주석

  1. 이미지 출처는 reddit.com