


First, let us look at conveniences which let us streamline our code a bit. Instead of just assigning a short synonym to string_map we can include it, dumping all of its exported symbols directly into our local namespace. Doing this with very many packages will make your local namespace a hopeless mess, but it makes sense to do now and then when you are using a particular package quite heavily.
Also, instead of using the set function we can use the shorter binary-operator synonym $ for it:
#!/usr/bin/mythryl
include string_map;
m = (empty: Map( String ));
m = m $ ("Key1", "Value1");
m = m $ ("Key2", "Value2");
m = m $ ("Key3", "Value3");
printf "%s -> %s\n" "Key1" (the (get (m, "Key1")) );
printf "%s -> %s\n" "Key2" (the (get (m, "Key2")) );
printf "%s -> %s\n" "Key3" (the (get (m, "Key3")) );
The run is unchanged:
linux$ ./my-script
Key1 -> Value1
Key2 -> Value2
Key3 -> Value3
Like C, Mythryl lets us abbreviate constructs like
foo = foo $ bar;
as simply
foo $= bar;
We can make our above script even a bit more compact by using this contraction. This is satisfyingly concise when used in code doing a lot of data accumulation in trees:
#!/usr/bin/mythryl
include string_map;
m = (empty: Map( String ));
m $= ("Key1", "Value1");
m $= ("Key2", "Value2");
m $= ("Key3", "Value3");
printf "%s -> %s\n" "Key1" (the (get (m, "Key1")) );
printf "%s -> %s\n" "Key2" (the (get (m, "Key2")) );
printf "%s -> %s\n" "Key3" (the (get (m, "Key3")) );
The run is again unchanged:
linux$ ./my-script
Key1 -> Value1
Key2 -> Value2
Key3 -> Value3


