load "../logo/printer.lg load "../logo/types.lg to env_new :outer :binds :exprs localmake "data [] if not emptyp :binds [ localmake "i 0 while [:i < _count :binds] [ ifelse (nth :binds :i) = [symbol &] [ localmake "val drop :exprs :i make "i (:i + 1) localmake "key nth :binds :i ] [ localmake "val nth :exprs :i localmake "key nth :binds :i ] make "data hashmap_put :data :key :val make "i (:i + 1) ] ] output listtoarray list :outer :data end to env_outer :env output item 1 :env end to env_data :env output item 2 :env end to env_find :env :key if emptyp :env [output []] localmake "val hashmap_get env_data :env :key ifelse emptyp :val [ output env_find env_outer :env :key ] [ output :env ] end to env_get :env :key localmake "foundenv env_find :env :key if emptyp :foundenv [(throw "error sentence (word "' pr_str :key "true "' ) [not found])] output hashmap_get env_data :foundenv :key end to env_set :env :key :val .setitem 2 :env hashmap_put env_data :env :key :val output :val end