Recently, I was playing around with inverted tables, specifically (from https://code.jsoftware.com/wiki/Essays/Inverted_Table):
ifa =: <@(>"1)@|: NB. inverted from atoms afi =: |:@:(<"_1@>) NB. atoms from inverted x0=: ];._1 ' Smith Jones Chan Wilson Saxon Angelo Smith Wilson' x1=: ];._1 ' John Dakota Wilson Diana Joan Roberto John John' x2=: 0 1 0 1 1 0 0 1 x3=: 23 29 47 23 31 19 23 23 x4=: 1.25 0.97 2.11 1.25 2.8 1.11 1.25 1.25 x=: x0;x1;x2;x3;x4 It occured to me both operations afi and ifa are (or should be) actually inverses of each other, but was baffled to find for once J did not work as expected: afi b. _1 <@(>"_1)@:|: ifa <@(>"1)@|: x -: ifa afi x 1 x -: afi inv afi x |domain error | x-: afi inv afi x <@(>"1) |: afi x ┌──────┬───────┬───────────────┬───────────────────────┬──────────────────────────────────────┐ │Smith │John │0 1 0 1 1 0 0 1│23 29 47 23 31 19 23 23│1.25 0.97 2.11 1.25 2.8 1.11 1.25 1.25│ │Jones │Dakota │ │ │ │ │Chan │Wilson │ │ │ │ │Wilson│Diana │ │ │ │ │Saxon │Joan │ │ │ │ │Angelo│Roberto│ │ │ │ │Smith │John │ │ │ │ │Wilson│John │ │ │ │ └──────┴───────┴───────────────┴───────────────────────┴──────────────────────────────────────┘ <@(>"_1) |: afi x |domain error | <@(>"_1)|:afi x |: afi x ┌───────┬───────┬───────┬───────┬───────┬───────┬───────┬───────┐ │Smith │Jones │Chan │Wilson │Saxon │Angelo │Smith │Wilson │ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤ │John │Dakota │Wilson │Diana │Joan │Roberto│John │John │ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤ │0 │1 │0 │1 │1 │0 │0 │1 │ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤ │23 │29 │47 │23 │31 │19 │23 │23 │ ├───────┼───────┼───────┼───────┼───────┼───────┼───────┼───────┤ │1.25 │0.97 │2.11 │1.25 │2.8 │1.11 │1.25 │1.25 │ └───────┴───────┴───────┴───────┴───────┴───────┴───────┴───────┘ As far as I understood, >"_1 and >"1 on a rank 2 array should be identical, shouldn't they? Apparently dissect also chokes on this sentence, as well as the "correct" one: load 'debug/dissect' dissect '<@(>"_1) |: afi x' NB. problematic sentence assertion failure |assertion failure: traversedowncalcselect | ((*/frame)>#selx)+.(*/frame)=#selx['travdowncalcselect' Error during initial display dissect '<@(>"1) |: afi x' error in paint domain error |domain error: cd | glrect 0 0 1 1+"1^:(-.IFQT),"2|."1 y If not for these oddities, it looks like the inverses of afi and ifa would be correctly derived by J, as I expected: afi |:@:(<"_1@>) ifa b. _1 |:@(<"1@>) ifa <@(>"1)@|: afi b. _1 <@(>"_1)@:|: I'm curious what your take is on this. Best regards, Jan-Pieter ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
