'length error and unexpected result trying to update dictionary of dictionaries

I am using a dictionary to keep track of a few state variables in a simulation engine am writing. The state variables can be tables, other dictionaries, etc.

I need to update these state variables - following tries to update the dictionary a[invt][rfqfills] and causes first a 'length error which I don’t quite get. And subsequently you find that it has partially updated the dictionary after all - which seems like a bug to me.

a:(marketinvt)!(( foo:til 3; bar:baz);(enlist rfqfills)!enlist (enlist`US80282KAE64)!(enlist -24f))

a[invt;rfqfills]~(enlist `US80282KAE64)!enlist -24f

a[`invt;`rfqfills;`US80282KAE64] / -24f

a[`invt;`rfqfills;`foo] / 0nf

a[invt;rfqfills]:(US80282KAE64US00206RCN08)!-24 -15f / 'length - why?

a[invt;rfqfills]~(US80282KAE64US00206RCN08)!-24 0nf / updates!! - why?

Tahsin Alam

tahsin@alum.mit.edu

https://www.linkedin.com/in/tahsinialam

I think the root of the problem is that the data structure in “a,” in particular, a[invt;rfqfills] is not the same as what you would expect in the first place.

Due to the fact that enlisting a dict makes it a table, the structure of a is like this when shown:

q)a

market| +foobar!(0 1 2;bazbaz`baz)

invt | (,rfqfills)!+(,US80282KAE64)!,-24f

Note the “+” sign in front of `US80282KAE64 and double “,” in front of -24f.

I’m not sure if this is considered a “feature” or a “bug” though. @__@

In any case, given your use case, it’d be much simpler to just use the following:

q)aa.foo:(foo:til 3;bar:`baz)

q)aa.rfqfills:(1#`US80282KAE64)!1#-24f

q)aa

| ::

foo | +foobar!(0 1 2;bazbaz`baz)

rfqfills| (,`US80282KAE64)!,-24f

q)aa.rfqfills:(US80282KAE64US00206RCN08)!-24 -15f

q)aa

| ::

foo | +foobar!(0 1 2;bazbaz`baz)

rfqfills| US80282KAE64US00206RCN08!-24 -15f

q)aa.rfqfills,:(1#`another)!1#100f

q)aa

| ::

foo | +foobar!(0 1 2;bazbaz`baz)

rfqfills| US80282KAE64US00206RCN08`another!-24 -15 100f