diff options
author | Marvin Borner | 2022-07-16 23:36:46 +0200 |
---|---|---|
committer | Marvin Borner | 2022-07-16 23:36:46 +0200 |
commit | 4c7d4174a2fcdea74d332cf7b407d6234c06bb2d (patch) | |
tree | 60e068ff6bbd9f3c9b3b109ea3488fb386ef1b31 /src/Binary.hs | |
parent | 88b0f7ed4e9580956f3be1eb50ce7cb10668207e (diff) |
Got some things working
Diffstat (limited to 'src/Binary.hs')
-rw-r--r-- | src/Binary.hs | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/src/Binary.hs b/src/Binary.hs index 974bf8d..2a1c891 100644 --- a/src/Binary.hs +++ b/src/Binary.hs @@ -20,24 +20,8 @@ toBinary (Bruijn x ) = (replicate (x + 1) '1') ++ "0" toBinary (Abstraction exp ) = "00" ++ toBinary exp toBinary (Application exp1 exp2) = "01" ++ (toBinary exp1) ++ (toBinary exp2) --- Stolen from John Tromp --- fromBinary :: String -> Expression --- fromBinary = foldr --- (\x -> Abstraction . (Application . Application (Bruijn 0) . code $ x)) --- nil --- where --- nil = code '1' --- code '0' = Abstraction (Abstraction (Bruijn 1)) --- code '1' = Abstraction (Abstraction (Bruijn 0)) --- code x = fromBinary (showsBin 8 (ord x) "") --- showsBin n x = if n == 0 --- then id --- else let (x', b) = divMod x 2 in showsBin (n - 1) x' . (intToDigit b :) - --- https://github.com/ljedrz/blc/blob/master/src/encoding/binary.rs fromBinary' :: String -> (Expression, String) fromBinary' = \case - -- "" -> (Bruijn 0, "") '0' : '0' : rst -> let (exp, rst) = fromBinary' rst in (Abstraction exp, rst) '0' : '1' : rst -> |