Commit c6b49c55 authored by Frontull Samuel's avatar Frontull Samuel
Browse files

unString vs unChurch

parent d8515360
......@@ -44,22 +44,22 @@ second = \p -> p (\x -> \y -> y)
-- STRINGS
type LCStrT = forall a . a -> (a -> a) -> (a -> a) -> a
newtype LCStr = LCStr { unChurch :: LCStrT }
newtype LCStr = LCStr { unString :: LCStrT }
empty :: LCStr
empty = LCStr $ \x a b -> x
isempty :: LCStr -> LCBool
isempty = \s -> unChurch s true af af
isempty = \s -> unString s true af af
conc :: LCStr -> LCStr -> LCStr
conc = \y z -> LCStr $ \x a b -> unChurch y (unChurch z x a b) a b
conc = \y z -> LCStr $ \x a b -> unString y (unString z x a b) a b
prepa :: LCStr -> LCStr
prepa = \s -> LCStr $ \x a b -> a (unChurch s x a b)
prepa = \s -> LCStr $ \x a b -> a (unString s x a b)
prepb :: LCStr -> LCStr
prepb = \s -> LCStr $ \x a b -> b (unChurch s x a b)
prepb = \s -> LCStr $ \x a b -> b (unString s x a b)
nexta :: LCPair LCStr -> LCPair LCStr
nexta = \x -> pair (prepa (first x)) (first x)
......@@ -68,19 +68,19 @@ nextb :: LCPair LCStr -> LCPair LCStr
nextb = \x -> pair (prepb (first x)) (first x)
hd_a :: LCStr -> LCBool
hd_a = \s -> unChurch s false at af
hd_a = \s -> unString s false at af
hd_b :: LCStr -> LCBool
hd_b = \s -> unChurch s false af at
hd_b = \s -> unString s false af at
hd_eq :: LCStr -> LCStr -> LCBool
hd_eq = \x y -> lor (land (hd_a x) (hd_a y)) (land (hd_b x) (hd_b y))
hd :: LCStr -> LCStr
hd = \s -> LCStr $ \x a b -> unChurch s x (\y -> a x) (\y -> b x)
hd = \s -> LCStr $ \x a b -> unString s x (\y -> a x) (\y -> b x)
tl :: LCStr -> LCStr
tl = \s -> second (unChurch s (pair empty empty) nexta nextb)
tl = \s -> second (unString s (pair empty empty) nexta nextb)
eq :: LCStr -> LCStr -> LCBool
eq = ycomb (\f x y ->
......@@ -198,7 +198,7 @@ problem_3 = cons (pair bba b) (cons (pair b ab) (cons (pair a bba) nil))
-- Output functions
lcstr_tostr :: LCStr -> String
lcstr_tostr = \s -> unChurch s ("") (\a -> "a" ++ a) (\b -> "b" ++ b)
lcstr_tostr = \s -> unString s ("") (\a -> "a" ++ a) (\b -> "b" ++ b)
lcbool_tostr :: LCBool -> String
lcbool_tostr = \b -> ite b "True" "False"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment