implement cons on strings

This commit is contained in:
darkf 2013-10-23 15:15:34 -07:00
parent ce5083fad9
commit 0dcc1707ee
1 changed files with 9 additions and 0 deletions

View File

@ -199,6 +199,15 @@ patternBindings (IntP n) _ = Nothing
patternBindings UnitP UnitV = Just M.empty
patternBindings UnitP _ = Nothing
-- cons on strings
patternBindings (ConsP x (ListP [])) (StrV (y:[])) = patternBindings x (StrV [y])
patternBindings (ConsP xp xsp) (StrV (x:xs)) =
do
xe <- patternBindings xp (StrV [x])
xse <- patternBindings xsp $ StrV xs
Just $ M.union xe xse
-- cons on lists
patternBindings (ConsP x (ListP [])) (ListV (y:[])) = patternBindings x y
patternBindings (ConsP xp xsp) (ListV (x:xs)) =
do