Given a list 'keys of keys and 'vals of vals, this will produce a table of them:
(listtab (map list keys vals))
If you need to update an existing table (which we'll call 'tbl) just use 'each:
(each (k v) (map list keys vals)
(= tbl.k v))
Alternatively:
(map (fn (k v) (= tbl.k v)) keys vals)
All of these solutions rely on the fact that 'map is variadic. It takes any number of lists to map over, and the function is expected to take that number of arguments. For example:
That'll work fine, although the 'do in your function is unnecessary. Also, there is a macro 'or= that does precisely what your first line does (assigns a value to a place if it is nil):
I'm not sure how any of these can work for intializing a table that's not aleady a table...
(= k* '("1" "2" "3"))
(= v* '("One" "Two" "Three"))
assuming t* has not been set - this is what I get:
arc> (filltbl t* k* v*)
Error: "reference to undefined identifier: _t*"
or even:
arc> (filltbl 't* k* v*)
Error: "Can't set reference t* \"1\" \"One\""
so what am I missing ?
filltbl isn't a macro, nor does it affect the global namespace. As written, it just creates a table if its first arg is nil. Of course, this is useless unless it returns that table... oops.
You could push it onto Anarki. Other than that, there isn't much you can do to get it into a public arc.arc. It seems that if a function isn't used in the forum code, pg doesn't include it in the official release.