Skip to content

Instantly share code, notes, and snippets.

View jvranish's full-sized avatar

Job Vranish jvranish

  • Grand Rapids, MI
View GitHub Profile
@jvranish
jvranish / div2.hs
Created March 18, 2011 01:49 — forked from sw17ch/div2.hs
Simple natural number type
-- div2.hs
data Nat = Zero | Succ Nat
deriving (Eq, Ord)
instance Show Nat where
show a = show $ fromEnum a
instance Num Nat where
a + Succ b = Succ a + b
module Main where
import System.Environment
l v = f (reverse v) - 1
where
f ([]) = 0
f (x:xs) = (nmap x + 1) + baseLen * f xs
nmap x = fromJust $ lookup x $ zip base [0..]
base = ['a'..'z']