From: Michael Andreen Date: Sat, 11 Mar 2006 20:23:18 +0000 (+0000) Subject: foldr and zip instead of my own function X-Git-Url: https://ruin.nu/git/?p=proglang.git;a=commitdiff_plain;h=8687a7c6790e959242228d64c8c513771565f8c1 foldr and zip instead of my own function --- diff --git a/Interpret.hs b/Interpret.hs index 1938e55..0e39285 100644 --- a/Interpret.hs +++ b/Interpret.hs @@ -52,21 +52,13 @@ eval (EFunc i as) = do vs <- mapM eval as state <- get (ds,ss) <- lookup i $ functions state - modify (\s -> s{variables=[empty]}) - addParams vs ds + let m = foldr (\((Decl t i),v) m -> insert i v m) empty $ zip ds vs + in modify (\s -> s{variables=[m]}) mapM_ execute ss `catchError` (\_ -> return ()) - put state v <- lift $ takeMVar $ ret state + put state return v -addParams :: [Value] -> [Decl] -> StateT State IO () -addParams [] [] = return () -addParams (v:vs) ((Decl t i):ds) = do - state <- get - let (m:ms) = variables state in modify (\s -> s{variables=insert i v m:ms }) - addParams vs ds - - getWord :: IO String getWord = do c <- getChar