Skip to content
Snippets Groups Projects
Commit 6e7bfef2 authored by plw1g21's avatar plw1g21
Browse files

Changed the name of the hashmap to a more appropriate name

(HashTable->HashMap)

Currently I have only got the hashmap to accept string values, if I try
to store an int, then all hell breaks loose :(
parent ea9d6a67
Branches JulioWithHashTable
No related tags found
No related merge requests found
import qualified Data.Map as Map import qualified Data.Map as Map
import Data.IORef import Data.IORef
main :: IO ()
main = do
-- Create a new mutable map
julioHashMap <- newMap
-- insertMap will be called whenever an EqualsToken is located
insertMap julioHashMap "tile1" "valuesLoadedIn1"
insertMap julioHashMap "tile2" "42"
-- When a variable name is seen and not an equals, use "lookupMap"
val1 <- lookupMap julioHashMap "tile1"
val2 <- lookupMap julioHashMap "tile2"
val3 <- lookupMap julioHashMap "tile3" --No tile3 currently
-- Temporary just to check if working
putStrLn $ "tile1: " ++ show val1
putStrLn $ "tile2: " ++ show val2
type MutableMap a = IORef (Map.Map String a) type MutableMap a = IORef (Map.Map String a)
newMap :: IO (MutableMap a) newMap :: IO (MutableMap a)
......
...@@ -3,7 +3,6 @@ import Grammar ...@@ -3,7 +3,6 @@ import Grammar
import System.Environment import System.Environment
import Control.Exception import Control.Exception
import System.IO import System.IO
import JHashtable
main :: IO () main :: IO ()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment