14 lines
331 B
Haskell
14 lines
331 B
Haskell
module SkewNat where
|
|
|
|
type SkewNat = [Int] -- increasing list of powers of 2^{k+1}-1
|
|
|
|
inc :: SkewNat -> SkewNat
|
|
inc ws@(w1 : w2 : rest)
|
|
| w1 == w2 = 1 + w1 + w2 : rest
|
|
| otherwise = 1 : ws
|
|
inc ws = 1 : ws
|
|
|
|
dec :: SkewNat -> SkewNat
|
|
dec (1 : ws) = ws
|
|
dec (w : ws) = (w `div` 2) : (w `div` 2) : ws
|