Parcourir la source

Merge branch 'exo'

Answer to palindromic height exercice
DricomDragon il y a 5 ans
Parent
commit
c70e8c2815
1 fichiers modifiés avec 13 ajouts et 0 suppressions
  1. 13 0
      hpal.hs

+ 13 - 0
hpal.hs

@@ -0,0 +1,13 @@
+r n = rconcat n 0
+
+rconcat inv outv  =
+	if inv == 0
+	then outv
+	else rconcat (div inv 10) (outv * 10 + mod inv 10)
+
+ispal n = r n == n
+
+hpal n = 
+	if ispal n
+	then 0
+	else 1 + hpal (n + r n)