Skip to content

Instantly share code, notes, and snippets.

@aztek
Created January 8, 2022 22:42
Show Gist options
  • Save aztek/def775ae161205320c1746cd93a983d0 to your computer and use it in GitHub Desktop.
Save aztek/def775ae161205320c1746cd93a983d0 to your computer and use it in GitHub Desktop.
A Haskell quine that is also a palindrome
q="eurT=fmap const pure 'q' abs;eslaF=fmap const show q gcd;xam=fmap const pure '=' odd;denifednu=ip<>di;dns=eurT<>xam;tsf=dns<>eslaF;ip=pure$!tsf;di=fmap const pure q cos;ton=dna<$>unlines;dna=putStr`fmap`yna;yna=mappend<*>reverse;main=let erehw main=main in fmap const ton denifednu main"
eurT=fmap const pure 'q' abs;eslaF=fmap const show q gcd;xam=fmap const pure '=' odd;denifednu=ip<>di;dns=eurT<>xam;tsf=dns<>eslaF;ip=pure$!tsf;di=fmap const pure q cos;ton=dna<$>unlines;dna=putStr`fmap`yna;yna=mappend<*>reverse;main=let erehw main=main in fmap const ton denifednu main
niam undefined not tsnoc pamf ni niam=niam where tel=niam;esrever>*<dneppam=any;any`pamf`rtStup=and;senilnu>$<and=not;soc q erup tsnoc pamf=id;fst!$erup=pi;False><snd=fst;max><True=snd;id><pi=undefined;ddo '=' erup tsnoc pamf=max;dcg q wohs tsnoc pamf=False;sba 'q' erup tsnoc pamf=True
"niam undefined not tsnoc pamf ni niam=niam where tel=niam;esrever>*<dneppam=any;any`pamf`rtStup=and;senilnu>$<and=not;soc q erup tsnoc pamf=id;fst!$erup=pi;False><snd=fst;max><True=snd;id><pi=undefined;ddo '=' erup tsnoc pamf=max;dcg q wohs tsnoc pamf=False;sba 'q' erup tsnoc pamf=True"=q
@aztek
Copy link
Author

aztek commented Jan 8, 2022

# It's a quine
runhaskell Quinedrome.hs | diff Quinedrome.hs -

# It's a palindrome
ghc -e 'readFile "Quinedrome.hs" >>= putStr . reverse' | diff Quinedrome.hs -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment