Re: [Jforum] Problem with dictionary

21 views
Skip to first unread message

Henry Rich

unread,
Jan 14, 2026, 8:19:20 AM (2 days ago) Jan 14
to fo...@jsoftware.com
Order is

   values put keys

That accounts for a lot of it.

hhr



 
On 1/13/2026 11:41 PM, Devon McCormick wrote:
Hi - I was putting together an intro  to the new dictionary addon, at the latest NYCJUG meeting - https://code.jsoftware.com/wiki/NYCJUG/2026-01-13#Populating_a_Dictionary - and ran into some problems.

I want to build a dictionary with extended integers as a key and the factors of that integer as the corresponding value.  However, specifying ('keytype'; 'extended') did not allow me load my data.  As a work-around, I specified both key and value as type "extended" and was able to populate the dictionary but retrieval failed.

Most puzzlingly, it did not fail for every case so I must have done something right, or at least half-right.  Here's how to reproduce the issue:
   ]nums=. 1+10^i.5x    NB. extended integers as keys
2 11 101 1001 10001
   ]factors=. q:&.>nums  NB. factors as values
+-+--+---+-------+------+
|2|11|101|7 11 13|73 137|
+-+--+---+-------+------+
   params=: 'tree',&< ('keytype'; 'boxed') ,: ('valuetype'; 'boxed')
   prms=: params conew 'jdictionary'
   (":&.>nums) put__prms ":&.>factors    NB. Populate
   get__prms <":0{nums
+-+
|2|
+-+
   get__prms <":1{nums
+--+
|11|
+--+
   get__prms <":2{nums
+---+
|101|
+---+
   get__prms <":3{nums
|index error: get__prms
|get__prms[0]
      13!:19''
   get__prms <":4{nums
|index error: get__prms
|get__prms[0]
      13!:19''
   get__prms <":1{nums    NB. make sure this still works
+--+
|11|
+--+


Even more interestingly, when I did this same exercise with  nums=. 1+10^i.10x, only the gets for 1 & 2 worked - 0 failed.

Please let me know what you think.

Devon McCormick

To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.

Devon McCormick

unread,
Jan 14, 2026, 5:32:47 PM (2 days ago) Jan 14
to fo...@jsoftware.com
Thanks, Henry.  I was able to load my data as boxed literals by reversing my arguments to "put" but so far my attempts to use extended data types have failed.

In any case, my session should not crash this easily:
   load 'dictionary'
   factors=. q:&.>nums=. 1+10^i.5x
   prms=: ('tree',&< ('keytype'; 'extended') ,: ('valuetype'; 'extended')) conew 'jdictionary'
   factors put__prms nums
|domain error: put__prms
|put__prms[:0]
      13!:19''
   put__prms

Process shell<2> exited abnormally with code 5




Devon McCormick



Henry Rich

unread,
Jan 14, 2026, 6:05:11 PM (2 days ago) Jan 14
to fo...@jsoftware.com
Your factors are boxed, so your valuetype must be also.

In the first version tree maps don't do anything more than hash maps, which have been tested better.  The crash has been fixed since the beta went out.

Henry Rich

Reply all
Reply to author
Forward
0 new messages