wiki page note

20 views
Skip to first unread message

P Padil

unread,
Mar 21, 2026, 3:27:26 PM (6 days ago) Mar 21
to fo...@jsoftware.com
At the bottom of https://code.jsoftware.com/wiki/Vocabulary/curlylf#dyadic,
the table "Follow a chain of variable-length records”, it says x {~^:a: y "Produces list of starting positions. Limit all values of x to at most #x, then append _1 to the end of x. Discard the final starting position of _1.”

I must be missing some context, I do not see where the _1 is coming from. Is it assuming _1 is the marker for the end of each record?

Also, the table indicates that x and y are integers, but then it says "Limit all values of x to at most #x”. Should both x and y be integer arrays? Tried several experiments but J told me I had no clue what I was doing...

Any clarifications appreciated.

Thanks
Pete

Henry Rich

unread,
Mar 21, 2026, 11:01:24 PM (5 days ago) Mar 21
to fo...@jsoftware.com
   ]b =. 100 200 300 400 (+ i.)&.> 1 4 2 3  NB. 4 variable-length records
+---+---------------+-------+-----------+
|100|200 201 202 203|300 301|400 401 402|
+---+---------------+-------+-----------+
   ]r =. ; (>:@# , ])&.> b  NB. encode as length-then-data
2 100 5 200 201 202 203 3 300 301 4 400 401 402
   ]rr =. _1 ,~ (+ i.@#) r  NB. convert each len to index of next rcd
2 101 7 203 205 207 209 10 308 310 14 411 413 415 _1
   ]rcds =. rr {~^:a: 0   NB. find record positions
0 2 7 10 14 _1
   ]s =. 1 _1 +"1 (2) -~/\\ }: rcds  NB. convert to start/length of
each record
 1 1
 3 4
 8 2
11 3
   (,."1 s) <;.0 r  NB. extract data & box
+---+---------------+-------+-----------+
|100|200 201 202 203|300 301|400 401 402|
+---+---------------+-------+-----------+

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

P Padil

unread,
Mar 22, 2026, 12:12:41 AM (5 days ago) Mar 22
to fo...@jsoftware.com
Thanks for the example! (I would have figure it out by about the same time the sun is predicted to turn into a red giant.) Maybe the example would make a good essay. Thanks again.
Reply all
Reply to author
Forward
0 new messages