Re: [Jprogramming] Agenda on different versions ...
The result of v contains verb numbers for the cells of x/y. It also indicates the rank of those cells: the verbs execute on (-rv)-cells, where rv is the rank of the result of v. The text seems to me to describe the operation correctly, but as always you can change it if it is unclear. Your description of the operation is correct. Henry Rich On 12/26/2023 6:14 PM, Raul Miller wrote: I should add that the nuvoc has some examples of implied rank, but I can't figure out why a list of 10 numbers from an infinite ranked v means rank 0 while a list of five numbers from infinite ranked v means rank 1. I suspect what it's intended to mean is that the implied rank is _1 and "_1 on a rank 1 list acts at rank 0 and "_1 on a rank 2 list acts at rank 1. But that doesn't match the text of the description. -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Agenda on different versions ...
See https://code.jsoftware.com/wiki/System/ReleaseNotes/J902 Henry Rich On 12/26/2023 3:11 PM, Devon McCormick wrote: I don't know about the history but in 9.5.5 (under Windows 10): (0:`1: @. (2&|)) i.4 0 1 0 1 On Tue, Dec 26, 2023 at 7:44 AM Martin Kreuzer wrote: Dear all - This left me puzzled today; have I missed some developments ? (all in Console on Windows10) - v8.07 - (0:`1: @. (2&|)) i.1 |rank error | (0:`1:@.(2&|))i.1 - v9.0.1 - (0:`1: @. (2&|)) i.1 |rank error | (0:`1:@.(2&|))i.1 - v9.0.2 - (0:`1: @. (2&|)) i.4 0 1 0 1 (0:`1: @. (2&|)) i.5 |rank error | (0:`1:@.(2&|))i.5 - v9.5.1 - (0:`1: @. (2&|)) i.4 0 1 0 1 (0:`1: @. (2&|)) i.5 |rank error, executing monad (0:`1:)@.(2&|) |each gerund must return a result whose shape agrees with its inputs | (0:`1:@.(2&|))i.5 What did happen between v9.0.1 andv 9.0.2 ? -Martin -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] sorting using verb returing a boolean
When I was doing topo sort, it was for a sort tree that did one comparison per node. You were asking about comparisons that are more complex than simple numeric comparison. For the topo sort, the comparison was essentially the sign of the volume of a pyramid after a 3D rotation. For pruning, you are comparing two game positions to decide which one should be first analyzed further. The comparison may be quite involved. Henry Rich On 12/22/2023 12:47 AM, Elijah Stone wrote: For toposort, though, you'd presumably want a cleverer strategy than just sorting the nodes, doing a full graph traversal on each comparison. Alpha-beta pruning I don't know about. On Thu, 21 Dec 2023, Henry Rich wrote: Topological sorting was a big topic in graphics back in the day. I can imagine that during alpha -beta pruning you might run into some ordering requirements that require more than simple keys. Henry Rich On Thu, Dec 21, 2023, 9:56 PM Elijah Stone wrote: > The problem it has is that if elements compare equal but don't match then > it'll never get down to an array where ~.y has length 1. Right, of course. Shame on me for being lazy and not bothering to write out *./2 u/\y. > Modern quicksort hybrids ... always use one bit at a time. I am curious what applications there are that really need a user-specified comparison function (rather than just a sort key, like dyadic /: takes). -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] sorting using verb returing a boolean
Topological sorting was a big topic in graphics back in the day. I can imagine that during alpha -beta pruning you might run into some ordering requirements that require more than simple keys. Henry Rich On Thu, Dec 21, 2023, 9:56 PM Elijah Stone wrote: > > The problem it has is that if elements compare equal but don't match > then > > it'll never get down to an array where ~.y has length 1. > > Right, of course. Shame on me for being lazy and not bothering to write > out > *./2 u/\y. > > > Modern quicksort hybrids ... always use one bit at a time. > > I am curious what applications there are that really need a user-specified > comparison function (rather than just a sort key, like dyadic /: takes). > > > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] sorting using verb returing a boolean
(/: verb-to-put-cards-in-order) table-of-hands For poker, verb-to-put-cards-in-order is vtpcio =. '23456789TJQKA' (/: vtpcio) _5 ]\ 'A22345323452' 23452 23453 2 A Henry Rich On 12/21/2023 10:29 AM, 'Viktor Grigorov' via Programming wrote: The first example is lesser, my bad! Dec 21, 2023, 15:27 by programm...@jsoftware.com: I have a list that I would like to sort using a verb that outputs 0 or 1, depending on the two items compared. Since there are length-1 factorial possible pairings and hence booleans, I'd thought of the table. Here, the items are hands of playing cards. One hand is greater than another, if at any one the position, starting checking from the first, it holds a greater card. The types of card get assigned 0 through 12. 2 is greater than A 23452 is lesser than 23453 Dec 21, 2023, 15:19 by henryhr...@gmail.com: I don't understand the problem statement. Henry Rich On 12/21/2023 10:17 AM, 'Viktor Grigorov' via Programming wrote: Maybe a table, summation and a sort using that: (/: ([:+/(>/]))) _10 1 10 20 _30 15 25 30 0 Can't imagine that being efficient, but it's better than nothing. The verb I'd defined can't deal with rank 2 nouns anyways. Dec 21, 2023, 14:21 by programm...@jsoftware.com: Not quite though. Had I 5 hands, that'd be !4 booleans. Dec 21, 2023, 14:11 by programm...@jsoftware.com: 1 0 0 1 0 /:~ i.5 1 2 4 0 3 On Thursday, December 21, 2023 at 09:03:34 a.m. EST, 'Viktor Grigorov' via Programming wrote: Hey, Is there an easy way to sort an array with verb returning either 0 or 1, like the comparison primitives? The verb that I'd in mind relates to the 2023's advent of code's day 7: given two equal length hands, which one has the first high card. Which one can write as: 'K2345' ( 2 | 0 { [: I. [: , [: (<,.>)/ ,: & ('23456789TJQKA'i.]) ) 'KJ2KA' 0 NB. here meaning left is not greater right Cheers, -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] sorting using verb returing a boolean
I don't understand the problem statement. Henry Rich On 12/21/2023 10:17 AM, 'Viktor Grigorov' via Programming wrote: Maybe a table, summation and a sort using that: (/: ([:+/(>/]))) _10 1 10 20 _30 15 25 30 0 Can't imagine that being efficient, but it's better than nothing. The verb I'd defined can't deal with rank 2 nouns anyways. Dec 21, 2023, 14:21 by programm...@jsoftware.com: Not quite though. Had I 5 hands, that'd be !4 booleans. Dec 21, 2023, 14:11 by programm...@jsoftware.com: 1 0 0 1 0 /:~ i.5 1 2 4 0 3 On Thursday, December 21, 2023 at 09:03:34 a.m. EST, 'Viktor Grigorov' via Programming wrote: Hey, Is there an easy way to sort an array with verb returning either 0 or 1, like the comparison primitives? The verb that I'd in mind relates to the 2023's advent of code's day 7: given two equal length hands, which one has the first high card. Which one can write as: 'K2345' ( 2 | 0 { [: I. [: , [: (<,.>)/ ,: & ('23456789TJQKA'i.]) ) 'KJ2KA' 0 NB. here meaning left is not greater right Cheers, -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Horse straggles cart
This follows the parsing rules. f is executed when the pattern N V V N is seen on the execution stack. GLOBAL has already been stacked at that point, as an undefined verb. When later GLOBAL is to be executed, its value has been changed to a noun. That pun is disallowed. Henry Rich On Sun, Dec 17, 2023, 2:03 PM David Lambert wrote: > $ ijconsole > > f=: {{ GLOBAL=: 'global defined here' }} > > GLOBAL [ f'' > |domain error in GLOBAL, executing monad GLOBAL > | GLOBAL[f'' > > GLOBAL [ f'' > global defined here > > JVERSION > Engine: j9.5.0-beta9/j64avx2/linux > Build: commercial/2023-12-06T14:16:14/clang-11-0-0/SLEEF=1 > Library: 9.5.5 > Platform: Linux 64 > Installer: unknown > InstallPath: /usr/share/j/9.5 > Contact:www.jsoftware.com > > Be well, Dave. > > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] sparse element changes unexpectedly
It's expected. If you kept the sparse element at 0 the matrix would become dense. 3 $. -. $. 3 3 $ _4 {. 1 1 3 $. 1 - $. 3 3 $ _4 {. 1 1 3 $. 2 - $. 3 3 $ _4 {. 1 2 3 $. % $. 3 3 $ _4 {. 1 _ Henry Rich On 12/11/2023 11:53 AM, David Lambert wrote: $ ijconsole JVERSION Engine: j9.5.0-beta9/j64avx2/linux Build: commercial/2023-12-06T14:16:14/clang-11-0-0/SLEEF=1 Library: 9.5.5 Platform: Linux 64 Installer: unknown InstallPath: /usr/share/j/9.5 Contact: www.jsoftware.com ]A=: 3 3 $ _4 {. 1 0 0 0 1 0 0 0 1 0 3 $. $. A 0 3 $. -. $. 3 3 $ _4 {. 1 1 -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Get all indexes of a boolean array
($ #: I.@,) y Henry Rich On 12/11/2023 5:06 AM, LdBeth wrote: I've been running to too many situations that I uses 4$.$.y a lot to get indexes of all non zero elements to an array, I wonder if there are any alternative ways to do that in J, especially when y is a boolean array. Also monadic I. only works for 1D array, while ⍸ from APL works for higher dimension cases, how to implement this in J? LdBeth -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Six cards
I'll open with (2 3 $ <@|:@(6 5&($!._))@:>:@I."1@|.)&.|: #: >: i. 60 +-+-+ |1 11 21 31 41 51 | 8 13 26 31 44 57| |3 13 23 33 43 53 | 9 14 27 40 45 58| |5 15 25 35 45 55 |10 15 28 41 46 59| |7 17 27 37 47 57 |11 24 29 42 47 60| |9 19 29 39 49 59 |12 25 30 43 56 _| +-+-+ | 2 11 22 31 42 51|16 21 26 31 52 57| | 3 14 23 34 43 54|17 22 27 48 53 58| | 6 15 26 35 46 55|18 23 28 49 54 59| | 7 18 27 38 47 58|19 24 29 50 55 60| |10 19 30 39 50 59|20 25 30 51 56 _| +-+-+ | 4 13 22 31 44 53|32 37 42 47 52 57| | 5 14 23 36 45 54|33 38 43 48 53 58| | 6 15 28 37 46 55|34 39 44 49 54 59| | 7 20 29 38 47 60|35 40 45 50 55 60| |12 21 30 39 52 _|36 41 46 51 56 _| +-+-----+ Henry Rich On 12/10/2023 11:37 AM, bill lam wrote: https://ibb.co/XLn0bxH The each of the 6 cards is missing a number that is present in the remaining 5 cards. By asking a player a number is present in the card or not, the number can be deducted. Eg, 55 is missing in the top left card. The problem is to generate all 6 cards in J. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] A Dot-Graph Rotator
22j10 (* ^@:j.@:o.&(%&180)) 15 18.6622j15.3533 Make the middle part a named verb if you like. Henry Rich On 12/7/2023 11:48 AM, 'PMA' via Programming wrote: A slightly different approach. Rather than search out all alignments and then deduce their degrees of rotation, I mean now to specify as input the degrees for which rotations are to be generated. Example: given a graph of one dot -- 22j10 -- I'd input that value with a rotation choice -- 15 degrees counterclockwise -- and expect a single integer-rounded output value of approximately 19j15. (Those two "15"s are coincidental.) My question is, what J syntax will generate that output? Thanks again for your consideration! Peter A On 11/16/23 09:26, Henry Rich wrote: This is my reply to a question someone posed yesterday. This afternoon I will post a complete solution. It's like the puzzle problems I posed you, but just a little longer and comes from a real user need. If you want to solve it yourself you will need the primitives j. dyad, / monad, / dyad, ~, -. dyad, ^ monad, | dyad, -, /: dyad, *. monad hhr On 11/15/2023 6:49 PM, Henry Rich wrote: I would find the angles from each point to each other point, take modulus(pi/2), concatenate the list with its negative, and sort. Rotation by each angle produces a new alignment. Only J primitives are needed. Use complex numbers to represent the (x,y) values, and *. to convert to angles. Henry Rich On 11/15/2023 5:52 PM, 'PMA' via Wiki wrote: Dear J-Wiki, I want to make a script that, given the X/Y values of a 2D dot-graph, will rotate the graph around its designated origin, looking for instances of 2 or more points coming into new horizontal &/or vertical alignment, and at each such instance output the full set of current X/Y values (integer-rounded). Could you point me to the main needed ingredients? Thanks in advance, Peter Armstrong -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
[Jprogramming] J Viewer: resize browser
Changing the browser size changes by too much. In particular, there is no way to recover the initial 50% size. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] J Viewer Release
Real-time notes at installation... It said I needed SQlite and that it had put a line to that effect in term (all of which was true) --- will a new user understand this? --- It went ahead and launched J Viewer even without the SQL. I found that disconcerting but ignored it and went to term to run the line. I also put in the shortcut as recommended, and restarted J. After the restart I did ctrl-Shift-H for the shortcut, and it said my SQL was out of date. This seems uncalled for. I went to Package Manager and updated SQlite. Meanwhile J Viewer had been launched again, and I canceled it IIRC. Ctrl-Shift-H again, now no messages and J viewer comes up. There is a form, all empty. Typing into the Words and Phrase edit controls is disallowed. Eventually I see a big button with a message to the effect that the database needs updating, followed by ... . I took that as a request to click, and did. Boom! J Viewer comes to life, with primitives on the left. I click around, and NuVoc comes up on the right. Searches for words and phrases produce results. This is going to be great. Suggestions: 1. The 4 source buttons (Forum/GitHub/Wiki/Rosetta) come up unselected but act as if all 4 were selected. Thus when you select one, the others go away. I suggest initializing them to selected. 2. The Shortcut button really is 'Add a shortcut to your config files'. As such, it is never needed after initial use. I recommend removing it if there is a shortcut, and providing a menu to allow for the seldom-used action of deleting the shortcut. 3. Likewise, the huge buttons to refresh the local database and update the J Viewer exaggerate their importance. If you are refreshing the database weekly as you said, most users will never need to update by hand. I suggest moving these features to an 'Update' menu. The very first time, bring up a modal dialog to force the user to initialize the database. 4. Clicking the first line of the leftmost pane brings up a list of primitives. Hovering over a primitive brings up clickable links below; I suggest that the colored box for the primitive also be clickable. 5. There are edit controls labeled 'Phrase' and 'Words'. What's the difference? Is one J and the other English? 6. Please find a way to put Vocabulary/Foreigns and Vocabulary/SpecialCombinations into the left pane near the top. I refer to those all the time. Better, allow a user to lock a page pointer into the left pane. This is already easier to get around in than the Wiki, just because of decreased scrolling. Henry Rich On 11/23/2023 7:56 PM, Ed Gottsman wrote: load '~addons/gottsman63/jwikiviz/run.ijs' -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] A Dot-Graph Rotator?
]pts =. _2 ]\ 1 1 2 2 3 4 NB. points as (x,y) 1 1 2 2 3 4 ]zpts =. j./ |: pts NB. points in complex plane 1j1 2j2 3j4 zorigin =. 0j0 NB. verb to rotate points y counterclockwise by angle x rot =. {{ zorigin + (y-zorigin) * ^ j. x }}"0 _ NB. Get the angles to use. Each pairwise point difference is a vector. Calculate them, run NB. into a list, discard 0s, find the angle. Negate the angle so as to rotate CW (which puts y NB. values the same, and append a copy with pi/2 added (which rotation puts x values the same). NB. Force to quadrants I and II, discard duplicates, sort. ]angles =. /:~ ~. 1p1 | (, 0.5p1&+) - 12 o. 0 -.~ , -/~ zpts 0.463648 0.588003 0.785398 2.03444 2.1588 2.35619 NB. Rotate by each angle to see that coordinates match angles rot zpts 0.447214j1.34164 0.894427j2.68328 0.894427j4.91935 0.27735j1.38675 0.5547j2.7735 0.27735j4.9923 0j1.41421 0j2.82843 _0.707107j4.94975 _1.34164j0.447214 _2.68328j0.894427 _4.91935j0.894427 _1.38675j0.27735 _2.7735j0.5547 _4.9923j0.27735 _1.41421j1.11022e_16 _2.82843j2.22045e_16 _4.94975j_0.707107 Henry Rich On 11/16/2023 9:44 AM, 'PMA' via Programming wrote: Dear J-Programming Forum, I want to make a script that, given the X/Y values of a 2D dot-graph, will rotate the graph around its designated origin, looking for instances of 2 or more points coming into new horizontal &/or vertical alignment, and at each such instance output the full set of current X/Y values (integer-rounded). Could you point me to the main needed ingredients? Thanks in advance, Peter Armstrong -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] A Dot-Graph Rotator
This is my reply to a question someone posed yesterday. This afternoon I will post a complete solution. It's like the puzzle problems I posed you, but just a little longer and comes from a real user need. If you want to solve it yourself you will need the primitives j. dyad, / monad, / dyad, ~, -. dyad, ^ monad, | dyad, -, /: dyad, *. monad hhr On 11/15/2023 6:49 PM, Henry Rich wrote: I would find the angles from each point to each other point, take modulus(pi/2), concatenate the list with its negative, and sort. Rotation by each angle produces a new alignment. Only J primitives are needed. Use complex numbers to represent the (x,y) values, and *. to convert to angles. Henry Rich On 11/15/2023 5:52 PM, 'PMA' via Wiki wrote: Dear J-Wiki, I want to make a script that, given the X/Y values of a 2D dot-graph, will rotate the graph around its designated origin, looking for instances of 2 or more points coming into new horizontal &/or vertical alignment, and at each such instance output the full set of current X/Y values (integer-rounded). Could you point me to the main needed ingredients? Thanks in advance, Peter Armstrong -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] A Dot-Graph Rotator
I would find the angles from each point to each other point, take modulus(pi/2), concatenate the list with its negative, and sort. Rotation by each angle produces a new alignment. Only J primitives are needed. Use complex numbers to represent the (x,y) values, and *. to convert to angles. Henry Rich On 11/15/2023 5:52 PM, 'PMA' via Wiki wrote: Dear J-Wiki, I want to make a script that, given the X/Y values of a 2D dot-graph, will rotate the graph around its designated origin, looking for instances of 2 or more points coming into new horizontal &/or vertical alignment, and at each such instance output the full set of current X/Y values (integer-rounded). Could you point me to the main needed ingredients? Thanks in advance, Peter Armstrong -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Issue with dual/under
This seems like a useful feature and not difficult to implement. We can discuss here what should be supported. Morten's reservations (in the cited article) are reasonable. I note that J has semiduals, and that it would make sense to support structural under for dyads using semiduals. Henry Rich On Sat, Oct 14, 2023, 6:10 AM LdBeth wrote: > >>>>> In > >>>>> "'Viktor Grigorov' via Programming" > wrote: > > > Why does > > > (|. &. ,) i.3 3 > > > result in a domain error (likewise with &.:), while > > > ($ $ (|. @ ,) ) i.3 3 > > > doesn't? > > The domain error is raised by ,^:_1 and as in J and APL > the inverse of ravel is not defined in present time. > > This is not the first time people asking about this feature > and the APL community have given this a name "structural under" > > https://www.dyalog.com/blog/2023/01/structural-vs-mathematical-under/ > > >> ... an important reason was that Roger Hui wasn’t a big fan of the > >> proposed extension known as “structural under” > > ldbeth > > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Extracting content from nested data
Something like (<1 0)&{::@> data untested. Henry Rich On 9/29/2023 9:39 AM, Pablo Landherr wrote: I have the following *data=: dec_json {some data source}* *$data* 48 *{.data* ┌──┐ │┌─┬──┬┬─┬─┬───┬──┬──┬┐│ ││seriesId │source│shortDescription│midDescription │longDescription │groupId│observationMaxDate│observationMinDate│seriesClosed││ │├─┼──┼┼─┼─┼───┼──┼──┼┤│ ││SEKATSPMI│Nasdaq│ATS │ATS Austria, shilling│Austrian shilling│130 │2002-02-28 │1993-01-04 │json_true ││ │└─┴──┴┴─┴─┴───┴──┴──┴┘│ └──┘ *5{.seriesId=: >>0&{&.>1&{&.> data* SEKATSPMI SEKAUDPMI SEKBEFPMI SEKBRLPMI SEKCADPMI (Apologies if the boxes are wrapped and look confusing) I wonder if someone can suggest a more "elegant" expression than 0&{&.>1&{&.> from above? What I have works, but to me, it looks a bit ugly. Thank you, Pablo Landherr -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Rank difficulties
I agree with Ben here. Transposing arrays of rank > 2 has never seemed intuitive to me. Taking a single slice is just one dimension smaller than a transpose. Say I want a slice of a 3-d array: all the atoms that have the same x index. I should just... wait a minute, the remaining axes are y and z: what order should they have in the slice? I might want the axes to be y then z, or z then y. Far from being intuitive, 'slice' is ambiguous. I have to specify the order of the remaining axes as well. You don't notice this when you are dealing with tables, because there is only one remaining axis, but the ambiguity is always there when you deal with higher ranks. x {"r y takes a slice of y, discarding axis r and leaving the other axes in the original order. That's one of the (! <: # $ y) possible ways to take a slice on axis r. If you want one that changes the order of axes, you must then apply the appropriate transpose. In a scalar language where you have to list the order of axes every time you access an atom, the transpose is hidden beneath the index order, but it's still there. J forces you to confront it directly. Henry Rich On 9/7/2023 8:44 PM, Ben Gorte wrote: Hi Piet, Slicing is a pretty intuitive concept so why should it be so intricate and “hard"? Maybe this is one of the reasons why J is not as popular as it ought to be. In the defence of J we might consider that the intuition of slicing is a bit ambiguous, which is the dangerous sort. The mental model of a 3d array for some might be a booklet of printed pages on the desk in front of them. Indexing would be along [pages, lines, columns], with the origin at the top-far-left corner. However, others might have put the pages on the desk one by one and have page 0 at the bottom. I don't know about your application, but extra sympathy should go out to those who think about 3D in terms of x,y,z. The intuitive [page, line, column] correspond to their z, y and x, in that order. Moreover, x increases left to right, like column, but y goes opposite to line, and z opposite to page - the latter for some but not for others. Personally I have been working long and hard on the representation of 3D geographic scenes as 3d voxel arrays, and (hopefully) just before getting completely crazy from the above I decided to call my 3D-array indices [X,Y,Z] and stick to it. It helped; I regard my models as collections of vertical columns (the z dimension), spread over the (x,y) space, and I think that is perfectly intuitive. However, now I have verbs called Top, Front and Side, I think similar to what Piet was asking for, that generate 2D views and cross-sections of 3D voxel models ("viewmat Top scene", "viewmat Front building" etc.). What happens inside those is still a bit weird. Greetings, Ben On Fri, 8 Sept 2023 at 07:10, Piet de Jong wrote: Thanks for all the great suggestions which has helped me a lot. To my mind it does raise a couple of issues or questions. I’ll stick my head out with them, knowing there might be much blowback. But bear with me. Slicing is a pretty intuitive concept so why should it be so intricate and “hard"? Maybe this is one of the reasons why J is not as popular as it ought to be. I “love” J and always use it. But I have not been able to convince a single other person to take it up. I’m always wondering why? Does it mean it’s just too intricate for the average Joe. Most people on this forum I imagine love the intricacy and see it as an enjoyable challenge. But the average Joe just wants to solve problems as quickly as possible and get on with life, not waste time on challenging intricate puzzles. So perhaps J is too much “puzzle solving” rather than “problem solving” Notwithstanding the above — I’ll always stick with J. On 8 Sep 2023, at 04:22, Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote: Oops, I forgot o=. @: On Thu, Sep 7, 2023 at 1:27 PM Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote: The order of the last two appear "unnatural". (To my way of thinking at least) This seems to beg the question what is the natural order when slicing. The answer might depend on the intended usage of the verb that you have in mind. If, for example, you want to preserve the order of the remaining axes, then Henry's suggestion modified by Raul would work, $ Y=. i.2 3 4 5 2 3 4 5 slicep=. ~.@(, i.@#@$) |: ] (0 1 2 3) ($ o slicep"0 _) Y 2 3 4 5 3 2 4 5 4 2 3 5 5 2 3 4 Another possibility is to rotate the axes, slicer=. (|. i.@:#@:$@:]) |: ] (0 1 2 3) ($ o slicer"0 _) Y 2 3 4 5 3 4 5 2 4 5 2 3 5 2 3 4 I hope this helps On Wed, Sep 6, 2023 at 7:58 PM Piet de Jong wrote: This works! Except the ordering of the axes is slightly unusual to my way of thinking. For example suppose m=.i.3 3 3 is the “cube" be sliced and v is your verb. Then the items o
Re: [Jprogramming] Rank difficulties
Since you want all the slices, what you are looking for is a transpose. Maybe ~.@(, i.@#) |: ] Untested. Henry Rich On Wed, Sep 6, 2023, 6:10 PM Piet de Jong wrote: > Here is my “wish" > > A dyadic (tacit) verb such that x v y gives all the slices of y along > dimension x, where x is integer. That is to say > > i{ x v y > > is slice i of the array y along dimension x. > > Thanks for all your help! > > > On 7 Sep 2023, at 08:04, 'robert therriault' via Programming < > programm...@jsoftware.com> wrote: > > > > Or something like this? > > > >[n =. i. 2 2 2 > > 0 1 > > 2 3 > > > > 4 5 > > 6 7 > > ,./ n > > 0 1 4 5 > > 2 3 6 7 > > ($ $ (,@,./)) n > > 0 1 > > 4 5 > > > > 2 3 > > 6 7 > > > > Cheers, bob > > > > > >> On Sep 6, 2023, at 14:49, 'robert therriault' via Programming < > programm...@jsoftware.com> wrote: > >> > >> Hi Piet, > >> > >> Maybe show us what you would want to do with higher dimensions? Or a > less symmetric 2 dimensional shape? > >> > >> For shape 2 2, I would use the even simpler > >> > >> |: m > >> 0 2 > >> 1 3 > >> > >> Hope this helps. > >> > >> Cheers, bob > >> > >>> On Sep 6, 2023, at 14:26, Brian Schott wrote: > >>> > >>> ,./0 1 {"1 m > >> > >> -- > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > -- > > For information about J forums see http://www.jsoftware.com/forums.htm > > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Google Bard question.
This answer put in in mind of Mark Twain fulminations on James Fenimore Cooper: [Cooper thought] a man's mouth is a rolling-mill... converting four-foot pigs of thought into thirty-foot bars of conversational railroad iron by attenuation... Henry Rich On 8/29/2023 9:13 PM, Devon McCormick wrote: Try asking Bard about APL and matrix computations, then point out the deficiency in its previous answer and see what it says. On Tue, Aug 29, 2023 at 6:09 PM 'Skip Cave' via Programming < programm...@jsoftware.com> wrote: What are the best computer languages to deal with matrix operations? There are many programming languages that are well-suited for matrix operations. Here are some of the most popular ones: - MATLAB: MATLAB is a proprietary programming language developed by MathWorks. It is specifically designed for mathematical computing and has a wide range of built-in functions for matrix operations. MATLAB is a powerful language, but it can be expensive to license. [image: MATLAB programming language logo]Opens in a new window <https://en.wikipedia.org/wiki/MATLAB>en.wikipedia.org <https://en.wikipedia.org/wiki/MATLAB> MATLAB programming language logo - Python: Python is a general-purpose programming language that is becoming increasingly popular for scientific computing. It has a large and active community of developers, and there are many libraries available for matrix operations. Python is also free and open-source. [image: Python programming language logo]Opens in a new window <https://en.wikipedia.org/wiki/Python_(programming_language)> en.wikipedia.org <https://en.wikipedia.org/wiki/Python_(programming_language)> Python programming language logo - Julia: Julia is a relatively new programming language that is designed to be fast and efficient for numerical computing. It is still under development, but it has a growing community of users. [image: Julia programming language logo]Opens in a new window <https://en.wikipedia.org/wiki/Julia_(programming_language)> en.wikipedia.org <https://en.wikipedia.org/wiki/Julia_(programming_language)> Julia programming language logo - R: R is a statistical programming language that is widely used for data analysis. It has a number of built-in functions for matrix operations, and there are many additional libraries available. [image: R programming language logo]Opens in a new window <https://commons.wikimedia.org/wiki/File:R_logo.svg> commons.wikimedia.org <https://commons.wikimedia.org/wiki/File:R_logo.svg> R programming language logo - C/C++: C/C++ are compiled languages that are known for their speed and efficiency. They are not as well-suited for matrix operations as some of the other languages on this list, but they can be used for very large and complex calculations. [image: C programming language logo]Opens in a new window <https://commons.wikimedia.org/wiki/File:C_Programming_Language.svg> commons.wikimedia.org <https://commons.wikimedia.org/wiki/File:C_Programming_Language.svg> chevron_right C programming language logo The best language for you will depend on your specific needs and requirements. If you are looking for a powerful and versatile language with a wide range of built-in functions, then MATLAB is a good choice. If you are looking for a free and open-source language with a large community of users, then Python is a good option. If you need a language that is fast and efficient for numerical computing, then Julia is a good choice. If you are primarily interested in statistical analysis, then R is a good choice. And if you need a language that is very fast and efficient, then C/C++ are good choices. Ultimately, the best way to decide which language is right for you is to try them out and see which one you prefer. There are many resources available online and in libraries that can help you get started. Skip Cave Cave Consulting LLC -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Eigenvectors and eigenvalues of complex matrices
I don't know. The last I used it was years ago. I had to make new wrappers sometimes; it was straightforward. Henry Rich On 8/19/2023 5:35 PM, Piet de Jong wrote: Thank you! Very helpful. Are there an cgee*.ijs scripts equivalent to dgee*.ijs scripts? Or do they have to be crafted from eg their equivalent dgee*.ijs counterparts? On 20 Aug 2023, at 06:43, Henry Rich wrote: You need cgee* for complex. Henry Rich On 8/19/2023 4:03 PM, Piet de Jong wrote: I’ve just updated to J9.4 and Lapack2. The verb do_dgeev from math/lapack2 appears to work fine for real matrices. However it gives a “domain error" when applied to a complex matrices. Is this how it should be? Or I am missing something? -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Eigenvectors and eigenvalues of complex matrices
You need cgee* for complex. Henry Rich On 8/19/2023 4:03 PM, Piet de Jong wrote: I’ve just updated to J9.4 and Lapack2. The verb do_dgeev from math/lapack2 appears to work fine for real matrices. However it gives a “domain error" when applied to a complex matrices. Is this how it should be? Or I am missing something? -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Rank error from Amend
Look out, it's a trap! 7 2 is a single word (a 2-item list). You have to separate the numbers. 7 (2)} y 0 1 7 3 4 Henry Rich On 8/19/2023 10:46 AM, 'PMA' via Programming wrote: NB. Dear J gurus -- NB. I'm having trouble with x m} y NB. Given a character array, it works: y =: '01234' y =: '7' 2} y y 01734 NB. But with a numbers array, No: y =: 0 1 2 3 4 y =: 7 2} y |rank error | y=: 7 2} y y 0 1 2 3 4 NB. How can I fix this? NB. Thanks in advance! NB. Peter A. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
??? J doesn't use unprintable characters. The result of 1!:1 is a string, whether the data comes from keyboard or a file. Henry Rich On 8/16/2023 11:29 AM, Ak O wrote: What are the unprintable characters that set 'n' to string? Ak On Wed., Aug. 16, 2023, 09:17 Henry Rich, wrote: extd =: 4 : 0 n=. ((1!:1) 1) ((".@,&'x' n)) A. i. x ) 30 extd '' 180548043269214561950911457875657 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 180548043269214561950911457875657x A. i. 30 NB. to check 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 1. done 2. y is immaterial 3. n is set to a string 3a. string has 'x' appended, is convert to (extended integer) number, used in A. Henry Rich On 8/16/2023 9:00 AM, Ak O wrote: Hi guys, I hope you are all well. Thank you for continuing to look at this. Can you please explain through each step how this function is parsed/processed? Please run it. Give attention to your behavior through each step. Step1. Function definition. Input the function and hit crtl-Enter on the first line. extd =: 4 : 0 n=. ((1!:1) 1) ((".@,&'x' n)) A. i. x ) Step 2. Function execution with inputs. Input the value and hit ctrl-Enter. 30 extd 180548043269214561950911457875657 Step 3. The function escapes for an input. Keyboard input. Input the characters and hit Enter. 180548043269214561950911457875657 Step 4. Result returned. Thank you. Ak On Tue., Aug. 15, 2023, 08:02 Henry Rich, wrote: Yes, maybe that's where the wrongthink is. In J terminology, the sentence is first converted to /words/ (most languages call these 'tokens'), with the words /evaluated/ as far as they can be in isolation. Anything that would be called a /self-defining term/ is given a type at this stage. For example, * is evaluated to be a primitive verb & is evaluated to be a primitive conjunction ( is evaluated to ( 'abc' is evaluated to a noun 123x is evaluated to an extended integer 5 12345678901234567890 (a single word) is evaluated to a list of 2 floating-point integers non-self-defining words are given a special type: foo is evaluated to a name After the words have been given types and maybe values, they are processed right to left according to the parsing rules. During the parsing, a name is looked up and replaced by its stored type/value (except when it is followed by an assignment copula =. or =:). On 8/15/2023 9:51 AM, Raul Miller wr Henry Rich ote: I think the inconsistency here is that you're thinking of a rather elaborate parsing system used by some other language. Brief overview of J's parser: A sentence is parsed first by tokenizing it (left to right), then the resulting array of tokens is passed to a shift/reduce parser (right to left). Conversion of numbers from "sequence of characters" to "1 or more numbers" happens during tokenization. Verbs execute during the shift/reduce stage. See also https://www.jsoftware.com/help/dictionary/dicte.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
extd =: 4 : 0 n=. ((1!:1) 1) ((".@,&'x' n)) A. i. x ) 30 extd '' 180548043269214561950911457875657 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 180548043269214561950911457875657x A. i. 30 NB. to check 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 1. done 2. y is immaterial 3. n is set to a string 3a. string has 'x' appended, is convert to (extended integer) number, used in A. Henry Rich On 8/16/2023 9:00 AM, Ak O wrote: Hi guys, I hope you are all well. Thank you for continuing to look at this. Can you please explain through each step how this function is parsed/processed? Please run it. Give attention to your behavior through each step. Step1. Function definition. Input the function and hit crtl-Enter on the first line. extd =: 4 : 0 n=. ((1!:1) 1) ((".@,&'x' n)) A. i. x ) Step 2. Function execution with inputs. Input the value and hit ctrl-Enter. 30 extd 180548043269214561950911457875657 Step 3. The function escapes for an input. Keyboard input. Input the characters and hit Enter. 180548043269214561950911457875657 Step 4. Result returned. Thank you. Ak On Tue., Aug. 15, 2023, 08:02 Henry Rich, wrote: Yes, maybe that's where the wrongthink is. In J terminology, the sentence is first converted to /words/ (most languages call these 'tokens'), with the words /evaluated/ as far as they can be in isolation. Anything that would be called a /self-defining term/ is given a type at this stage. For example, * is evaluated to be a primitive verb & is evaluated to be a primitive conjunction ( is evaluated to ( 'abc' is evaluated to a noun 123x is evaluated to an extended integer 5 12345678901234567890 (a single word) is evaluated to a list of 2 floating-point integers non-self-defining words are given a special type: foo is evaluated to a name After the words have been given types and maybe values, they are processed right to left according to the parsing rules. During the parsing, a name is looked up and replaced by its stored type/value (except when it is followed by an assignment copula =. or =:). On 8/15/2023 9:51 AM, Raul Miller wr Henry Rich ote: I think the inconsistency here is that you're thinking of a rather elaborate parsing system used by some other language. Brief overview of J's parser: A sentence is parsed first by tokenizing it (left to right), then the resulting array of tokens is passed to a shift/reduce parser (right to left). Conversion of numbers from "sequence of characters" to "1 or more numbers" happens during tokenization. Verbs execute during the shift/reduce stage. See also https://www.jsoftware.com/help/dictionary/dicte.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
Yes, maybe that's where the wrongthink is. In J terminology, the sentence is first converted to /words/ (most languages call these 'tokens'), with the words /evaluated/ as far as they can be in isolation. Anything that would be called a /self-defining term/ is given a type at this stage. For example, * is evaluated to be a primitive verb & is evaluated to be a primitive conjunction ( is evaluated to ( 'abc' is evaluated to a noun 123x is evaluated to an extended integer 5 12345678901234567890 (a single word) is evaluated to a list of 2 floating-point integers non-self-defining words are given a special type: foo is evaluated to a name After the words have been given types and maybe values, they are processed right to left according to the parsing rules. During the parsing, a name is looked up and replaced by its stored type/value (except when it is followed by an assignment copula =. or =:). Henry Rich On 8/15/2023 9:51 AM, Raul Miller wrote: I think the inconsistency here is that you're thinking of a rather elaborate parsing system used by some other language. Brief overview of J's parser: A sentence is parsed first by tokenizing it (left to right), then the resulting array of tokens is passed to a shift/reduce parser (right to left). Conversion of numbers from "sequence of characters" to "1 or more numbers" happens during tokenization. Verbs execute during the shift/reduce stage. See also https://www.jsoftware.com/help/dictionary/dicte.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
My advice: learn to live with the quotes. You need a way to write a string that represents a long value. In J, that's 'longvaluex'. Henry Rich On 8/14/2023 10:57 PM, Ak O wrote: Hi Henry, Yes actually all I want is a verb that stting encloses an argument. After that I can attach ('.@,&'x') and have my extended type object. The difference between the two functions is that the second functions requires quotes about the 'y' to runs correctly. The first function does not require quotes as it looks for keyboard input to complete the execution correctly. Ak On Mon., Aug. 14, 2023, 20:01 Henry Rich, wrote: ". string executes the string. But it is a string, i. e. a literal. If you want that literal to contain a character string for execution, you must enclose that string in quotes. You can write a verb to do it. Henry Rich On 8/14/2023 9:14 PM, Ak O wrote: Is there a more simple way of feeding the interpreter? Meaning, is there some invisible trigger like a CR or a LF (unprintable characters) that is recognized by the interpreter as coming from the keyboard? There must be since, typing numbers only, physically on the keyboard and hitting enter runs the program correctly. Ak On Mon., Aug. 14, 2023, 17:43 Raul Miller, wrote: There's two ways of accomplishing what I think you are asking for. (1) Modify the J interpreter, or (2) Modify the J IDE. You could modify the interpreter such that large integers are treated as extended integers. (This might be a worthwhile change at some point in the future. The reasoning here would be that if the user has typed in all those digits, presumably they are significant.) You could modify the J IDE (to automatically add the trailing 'x' on long sequences of digits followed by a space). This would be considerably less desirable (since it could mess up literal text). The remaining option is to hit that 'x' key, yourself. I hope this makes sense, -- Raul On Mon, Aug 14, 2023 at 4:43 PM Ak O wrote: Hi Raul, Yes I think I understood Henry's message. This why my thought is to simulte the keyboard input. Since typing the raw input into the first function works exactly as desired. I want rather to substitute escaping to the keyboard for feeding the input as keystrokes. I don't know enough about stdin and keyboard reads to know the different triggers. Are there some bytes that the keyboard triggers that interpreter recognizes? If the analogy is writing/reading a file, can i get the bytes of each digit and go from there? Is there better was for me to think about this? Probably. But, I know that if a keyboard can do it, I can simulate a keyboard doing it. I must be able to run that track without needing to escape the function. :) Ak On Mon., Aug. 14, 2023, 13:30 Raul Miller, wrote: I think you should re-read Henry's message that you were responding to here. By the time any J function can run, it's already too late. -- Raul On Mon, Aug 14, 2023 at 12:58 PM Ak O wrote: What expression allows a function to recieve an argument 'y' as a literal without using quotes? Below are two deficient functions. The size of the vector is given by 'x'. The permutation index is meant to be given by 'y'. My intention is treat 'y' as a literal, without needing to use quotes on the input. This first function works by escaping to the keyboard for input I would like rather for the function to receive the input from the raw argument and not have to escape to the keyboard. Desired Input 30 extd 180548043269214561950911457875657 Rather than 30 extd '180548043269214561950911457875657' This function is deficient by its operating sequence. It escapes to keyboard, which preservs the literal type. extd =: 4 : 0 n=. ((1!:1) 1 ((".@,&'x' n)) A. i. x ) 30 extd 180548043269214561950911457875657 Keyboard input (if this approach makes sense, can the keyboard input be simulated by using y as the feed?) 180548043269214561950911457875657 Result 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 Alternative deficient function by the input form. Yields the correct result but uses quotes in the input. extdquotes =: 4 : 0 ((".@,&'x' n)) A. i. x ) 30 extdquotes '180548043269214561950911457875657' Result 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 I am looking for the function that uses the input for extd that delivers the result of extdquotes Thank you for your help Ak On Sat., Aug. 12, 2023, 13:43 Henry Rich, wrote: It's like this: /long-number/ is a single word. If the length is <19 digits, it is an integer, otherwise a float (which necessarily has only 16 digits of precision). /long-number/x is a single word, but it is always an extended integer, and every digit of /long-number/ is preserved. x: /number/ is two words. /number/ is evaluated first, and then x: is applied to its value to give an extended integer. In t
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
". string executes the string. But it is a string, i. e. a literal. If you want that literal to contain a character string for execution, you must enclose that string in quotes. You can write a verb to do it. Henry Rich On 8/14/2023 9:14 PM, Ak O wrote: Is there a more simple way of feeding the interpreter? Meaning, is there some invisible trigger like a CR or a LF (unprintable characters) that is recognized by the interpreter as coming from the keyboard? There must be since, typing numbers only, physically on the keyboard and hitting enter runs the program correctly. Ak On Mon., Aug. 14, 2023, 17:43 Raul Miller, wrote: There's two ways of accomplishing what I think you are asking for. (1) Modify the J interpreter, or (2) Modify the J IDE. You could modify the interpreter such that large integers are treated as extended integers. (This might be a worthwhile change at some point in the future. The reasoning here would be that if the user has typed in all those digits, presumably they are significant.) You could modify the J IDE (to automatically add the trailing 'x' on long sequences of digits followed by a space). This would be considerably less desirable (since it could mess up literal text). The remaining option is to hit that 'x' key, yourself. I hope this makes sense, -- Raul On Mon, Aug 14, 2023 at 4:43 PM Ak O wrote: Hi Raul, Yes I think I understood Henry's message. This why my thought is to simulte the keyboard input. Since typing the raw input into the first function works exactly as desired. I want rather to substitute escaping to the keyboard for feeding the input as keystrokes. I don't know enough about stdin and keyboard reads to know the different triggers. Are there some bytes that the keyboard triggers that interpreter recognizes? If the analogy is writing/reading a file, can i get the bytes of each digit and go from there? Is there better was for me to think about this? Probably. But, I know that if a keyboard can do it, I can simulate a keyboard doing it. I must be able to run that track without needing to escape the function. :) Ak On Mon., Aug. 14, 2023, 13:30 Raul Miller, wrote: I think you should re-read Henry's message that you were responding to here. By the time any J function can run, it's already too late. -- Raul On Mon, Aug 14, 2023 at 12:58 PM Ak O wrote: What expression allows a function to recieve an argument 'y' as a literal without using quotes? Below are two deficient functions. The size of the vector is given by 'x'. The permutation index is meant to be given by 'y'. My intention is treat 'y' as a literal, without needing to use quotes on the input. This first function works by escaping to the keyboard for input I would like rather for the function to receive the input from the raw argument and not have to escape to the keyboard. Desired Input 30 extd 180548043269214561950911457875657 Rather than 30 extd '180548043269214561950911457875657' This function is deficient by its operating sequence. It escapes to keyboard, which preservs the literal type. extd =: 4 : 0 n=. ((1!:1) 1 ((".@,&'x' n)) A. i. x ) 30 extd 180548043269214561950911457875657 Keyboard input (if this approach makes sense, can the keyboard input be simulated by using y as the feed?) 180548043269214561950911457875657 Result 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 Alternative deficient function by the input form. Yields the correct result but uses quotes in the input. extdquotes =: 4 : 0 ((".@,&'x' n)) A. i. x ) 30 extdquotes '180548043269214561950911457875657' Result 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 I am looking for the function that uses the input for extd that delivers the result of extdquotes Thank you for your help Ak On Sat., Aug. 12, 2023, 13:43 Henry Rich, wrote: It's like this: /long-number/ is a single word. If the length is <19 digits, it is an integer, otherwise a float (which necessarily has only 16 digits of precision). /long-number/x is a single word, but it is always an extended integer, and every digit of /long-number/ is preserved. x: /number/ is two words. /number/ is evaluated first, and then x: is applied to its value to give an extended integer. In that last case, if /number/ has more than 19 digits, it will have been represented as a float, and the extended integer will have only 16 digits of precision. Henry Rich On 8/12/2023 3:25 PM, Ak O wrote: My thought was that 'x' must always be extended by definition. I was trying to think what cases this operator's 'x' argument would not be strictly extended. Chris demonstrated that the input 'x' in my example is float by construction. Raul explained that the parser treats the number before it treats the operator ( if I have understood his message correctly). So if I have understood all of this
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
Why is extd a dyad? Otherwise, this seems to work. What is deficient? Henry Rich On 8/14/2023 8:38 PM, Ak O wrote: extd =: 4 : 0 n=. ((1!:1) 1 ) ((".@,&'x' n)) A. i. x ) -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
You have a mismatched parenthesis in the prompt line of the verb you posted. Henry Rich On 8/14/2023 4:42 PM, Ak O wrote: Hi Raul, Yes I think I understood Henry's message. This why my thought is to simulte the keyboard input. Since typing the raw input into the first function works exactly as desired. I want rather to substitute escaping to the keyboard for feeding the input as keystrokes. I don't know enough about stdin and keyboard reads to know the different triggers. Are there some bytes that the keyboard triggers that interpreter recognizes? If the analogy is writing/reading a file, can i get the bytes of each digit and go from there? Is there better was for me to think about this? Probably. But, I know that if a keyboard can do it, I can simulate a keyboard doing it. I must be able to run that track without needing to escape the function. :) Ak On Mon., Aug. 14, 2023, 13:30 Raul Miller, wrote: I think you should re-read Henry's message that you were responding to here. By the time any J function can run, it's already too late. -- Raul On Mon, Aug 14, 2023 at 12:58 PM Ak O wrote: What expression allows a function to recieve an argument 'y' as a literal without using quotes? Below are two deficient functions. The size of the vector is given by 'x'. The permutation index is meant to be given by 'y'. My intention is treat 'y' as a literal, without needing to use quotes on the input. This first function works by escaping to the keyboard for input I would like rather for the function to receive the input from the raw argument and not have to escape to the keyboard. Desired Input 30 extd 180548043269214561950911457875657 Rather than 30 extd '180548043269214561950911457875657' This function is deficient by its operating sequence. It escapes to keyboard, which preservs the literal type. extd =: 4 : 0 n=. ((1!:1) 1 ((".@,&'x' n)) A. i. x ) 30 extd 180548043269214561950911457875657 Keyboard input (if this approach makes sense, can the keyboard input be simulated by using y as the feed?) 180548043269214561950911457875657 Result 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 Alternative deficient function by the input form. Yields the correct result but uses quotes in the input. extdquotes =: 4 : 0 ((".@,&'x' n)) A. i. x ) 30 extdquotes '180548043269214561950911457875657' Result 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 I am looking for the function that uses the input for extd that delivers the result of extdquotes Thank you for your help Ak On Sat., Aug. 12, 2023, 13:43 Henry Rich, wrote: It's like this: /long-number/ is a single word. If the length is <19 digits, it is an integer, otherwise a float (which necessarily has only 16 digits of precision). /long-number/x is a single word, but it is always an extended integer, and every digit of /long-number/ is preserved. x: /number/ is two words. /number/ is evaluated first, and then x: is applied to its value to give an extended integer. In that last case, if /number/ has more than 19 digits, it will have been represented as a float, and the extended integer will have only 16 digits of precision. Henry Rich On 8/12/2023 3:25 PM, Ak O wrote: My thought was that 'x' must always be extended by definition. I was trying to think what cases this operator's 'x' argument would not be strictly extended. Chris demonstrated that the input 'x' in my example is float by construction. Raul explained that the parser treats the number before it treats the operator ( if I have understood his message correctly). So if I have understood all of this correctly. As a raw input, it is the extended representation of the float input 'x' that is actually what is being operated on by A. to yield the result. Ak On Sat., Aug. 12, 2023, 11:34 Henry Rich, wrote: I misunderstood your question. (x A. y) starts by verifying that (*./ (|x) < !.#y) and then converts x to a permutation with (i.@-&.<: y) #: x (all in extended precision if x is extended), followed by a number of rotations within an index vector. It is much less work to start with the permutation vector rather than the anagram index. Henry Rich On 8/11/2023 8:29 PM, Ak O wrote: For me, (x: y) does not preserve the input. The result I get is not the same. ( x:180548043269214561950911457875657 ) 180548043269214573494164592263168 This does not work. 180548043269214561950911457875657x 180548043269214561950911457875657 This does work. On Fri., Aug. 11, 2023, 13:01 Henry Rich, wrote: (x: value) produces extended version of value. Henry Rich On Fri, Aug 11, 2023, 2:44 PM Ak O wrote: Hi everybody, I hope you are all well. I have a question about the Anagram ( A. ) operator. In a defined function, how do I designate that an input 'x' is treatment as extended datatype rather than float? Where
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
It's like this: /long-number/ is a single word. If the length is <19 digits, it is an integer, otherwise a float (which necessarily has only 16 digits of precision). /long-number/x is a single word, but it is always an extended integer, and every digit of /long-number/ is preserved. x: /number/ is two words. /number/ is evaluated first, and then x: is applied to its value to give an extended integer. In that last case, if /number/ has more than 19 digits, it will have been represented as a float, and the extended integer will have only 16 digits of precision. Henry Rich On 8/12/2023 3:25 PM, Ak O wrote: My thought was that 'x' must always be extended by definition. I was trying to think what cases this operator's 'x' argument would not be strictly extended. Chris demonstrated that the input 'x' in my example is float by construction. Raul explained that the parser treats the number before it treats the operator ( if I have understood his message correctly). So if I have understood all of this correctly. As a raw input, it is the extended representation of the float input 'x' that is actually what is being operated on by A. to yield the result. Ak On Sat., Aug. 12, 2023, 11:34 Henry Rich, wrote: I misunderstood your question. (x A. y) starts by verifying that (*./ (|x) < !.#y) and then converts x to a permutation with (i.@-&.<: y) #: x (all in extended precision if x is extended), followed by a number of rotations within an index vector. It is much less work to start with the permutation vector rather than the anagram index. Henry Rich On 8/11/2023 8:29 PM, Ak O wrote: For me, (x: y) does not preserve the input. The result I get is not the same. ( x:180548043269214561950911457875657 ) 180548043269214573494164592263168 This does not work. 180548043269214561950911457875657x 180548043269214561950911457875657 This does work. On Fri., Aug. 11, 2023, 13:01 Henry Rich, wrote: (x: value) produces extended version of value. Henry Rich On Fri, Aug 11, 2023, 2:44 PM Ak O wrote: Hi everybody, I hope you are all well. I have a question about the Anagram ( A. ) operator. In a defined function, how do I designate that an input 'x' is treatment as extended datatype rather than float? Where being defined: 13 : ' x A. i.y' [ A. [: i. ] is to be taken as, 13 : 'X_INPUTx A. y' NB. 12345672345467x A. i.y How do I get the affect of catenating an 'x' to the end of a number in a defined function? If you understand my question ignore below, otherwise I give an example. Thank you for your thoughts. Ak My understanding of the Anagram operator (A.). The vocabulary reference page (acapdot) gives the product of the Anagram index function A. y as datatype extended. The Anagram function x A. y applies the permutation map (x) on ordered vector sequence (y) as below. ]vector_sequence =: ?~30 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 ]vector_anagram =: A. vector_sequence 180548043269214561950911457875657 The Noun, vector_anagram will have datatype extended, given by: datatype vector_anagram extended Applying the vector_anagram on a vector using the command: vector_anagram A. i.30 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 The expected result. In a case where the digits are input on there own, the following fails with 'domain error, executing dyad A.' 180548043269214561950911457875657 A. i.30 One approach is to place 'x:' before the input. ( x:180548043269214561950911457875657 )A. i.30 20 12 4 29 7 17 22 11 2 27 28 25 1 8 0 15 16 14 3 5 19 26 18 6 21 23 13 24 9 10 This is not the expected result. The input is treated as 180548043269214573494164592263168. ( x:180548043269214561950911457875657 ) 180548043269214573494164592263168 Not the input I thought I was applying. An alternative is to postfix an 'x' to the end of the input. 180548043269214561950911457875657x A. i.30 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 The expected result. But how do I achieve this for a defined function. Does not work either. ".@((":vector_anagram),x')"_ NB. same as x: Maybe there is a symbol that 13 : can be recognize to trigger the extended datatype. Thank you for your help. Ak -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For informa
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
I misunderstood your question. (x A. y) starts by verifying that (*./ (|x) < !.#y) and then converts x to a permutation with (i.@-&.<: y) #: x (all in extended precision if x is extended), followed by a number of rotations within an index vector. It is much less work to start with the permutation vector rather than the anagram index. Henry Rich On 8/11/2023 8:29 PM, Ak O wrote: For me, (x: y) does not preserve the input. The result I get is not the same. ( x:180548043269214561950911457875657 ) 180548043269214573494164592263168 This does not work. 180548043269214561950911457875657x 180548043269214561950911457875657 This does work. On Fri., Aug. 11, 2023, 13:01 Henry Rich, wrote: (x: value) produces extended version of value. Henry Rich On Fri, Aug 11, 2023, 2:44 PM Ak O wrote: Hi everybody, I hope you are all well. I have a question about the Anagram ( A. ) operator. In a defined function, how do I designate that an input 'x' is treatment as extended datatype rather than float? Where being defined: 13 : ' x A. i.y' [ A. [: i. ] is to be taken as, 13 : 'X_INPUTx A. y' NB. 12345672345467x A. i.y How do I get the affect of catenating an 'x' to the end of a number in a defined function? If you understand my question ignore below, otherwise I give an example. Thank you for your thoughts. Ak My understanding of the Anagram operator (A.). The vocabulary reference page (acapdot) gives the product of the Anagram index function A. y as datatype extended. The Anagram function x A. y applies the permutation map (x) on ordered vector sequence (y) as below. ]vector_sequence =: ?~30 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 ]vector_anagram =: A. vector_sequence 180548043269214561950911457875657 The Noun, vector_anagram will have datatype extended, given by: datatype vector_anagram extended Applying the vector_anagram on a vector using the command: vector_anagram A. i.30 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 The expected result. In a case where the digits are input on there own, the following fails with 'domain error, executing dyad A.' 180548043269214561950911457875657 A. i.30 One approach is to place 'x:' before the input. ( x:180548043269214561950911457875657 )A. i.30 20 12 4 29 7 17 22 11 2 27 28 25 1 8 0 15 16 14 3 5 19 26 18 6 21 23 13 24 9 10 This is not the expected result. The input is treated as 180548043269214573494164592263168. ( x:180548043269214561950911457875657 ) 180548043269214573494164592263168 Not the input I thought I was applying. An alternative is to postfix an 'x' to the end of the input. 180548043269214561950911457875657x A. i.30 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 16 14 The expected result. But how do I achieve this for a defined function. Does not work either. ".@((":vector_anagram),x')"_ NB. same as x: Maybe there is a symbol that 13 : can be recognize to trigger the extended datatype. Thank you for your help. Ak -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Anagram Operator (A.) and Generalized Datatype declaration in function assignments.
(x: value) produces extended version of value. Henry Rich On Fri, Aug 11, 2023, 2:44 PM Ak O wrote: > Hi everybody, I hope you are all well. > > I have a question about the Anagram ( A. ) operator. > > In a defined function, how do I designate that an input 'x' is treatment > as extended datatype rather than float? > > Where being defined: > 13 : ' x A. i.y' > [ A. [: i. ] > > is to be taken as, > 13 : 'X_INPUTx A. y' NB. 12345672345467x A. i.y > > How do I get the affect of catenating an 'x' to the end of a number in a > defined function? > > If you understand my question ignore below, otherwise I give an example. > > Thank you for your thoughts. > > Ak > > > My understanding of the Anagram operator (A.). > The vocabulary reference page (acapdot) gives the product of the Anagram > index function > A. y > as datatype extended. > > > The Anagram function > x A. y > applies the permutation map (x) on ordered vector sequence (y) as below. > > > ]vector_sequence =: ?~30 > 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 > 16 14 > > > ]vector_anagram =: A. vector_sequence > 180548043269214561950911457875657 > > The Noun, vector_anagram will have datatype extended, given by: > datatype vector_anagram > extended > > Applying the vector_anagram on a vector using the command: > vector_anagram A. i.30 > 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 > 16 14 > > The expected result. > > In a case where the digits are input on there own, the following fails with > 'domain error, executing dyad A.' > > 180548043269214561950911457875657 A. i.30 > > One approach is to place 'x:' before the input. > ( x:180548043269214561950911457875657 )A. i.30 > 20 12 4 29 7 17 22 11 2 27 28 25 1 8 0 15 16 14 3 5 19 26 18 6 21 23 13 24 > 9 10 > > This is not the expected result. > > The input is treated as 180548043269214573494164592263168. > > ( x:180548043269214561950911457875657 ) > 180548043269214573494164592263168 > > Not the input I thought I was applying. > > An alternative is to postfix an 'x' to the end of the input. > 180548043269214561950911457875657x A. i.30 > 20 12 4 29 7 17 22 11 2 27 28 23 6 21 9 3 24 10 26 13 15 1 18 8 25 19 0 5 > 16 14 > > The expected result. But how do I achieve this for a defined function. > > Does not work either. > ".@((":vector_anagram),x')"_ NB. same as x: > > > Maybe there is a symbol that 13 : can be recognize to trigger the extended > datatype. > > > > Thank you for your help. > > Ak > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial
I am trying to write to users at the earnest-tire-kicker level and above: someone who has decided that J is worth a look and is deciding whether it's worth putting serious time into. [This is the same level of user that we aimed the first section of the NuVoc pages at]. If you're trying to understand a sentence I wrote, and after 5 minutes you still can't get it, that would be a good candidate for more words from me. Henry Rich On 8/5/2023 4:20 PM, More Rice wrote: [Henry] IF YOU ARE NEW TO J, you are the person I need to hear from. Where do I need to add explanatory material, or rewrite a section? Oh hey. I qualify for this one. :) Thank you for starting & sharing this. One thing I want to bring up - What are your reader's J prerequisites? It is well known the way a master organizes their specialized skill in their mind is different from newcomers. They knew all the idioms, phrases, what works and what doesn't ... it is easy to skip all the roadblocks/landmines for newcomers and just talk about the final answer in its full glory. (Not that I'm complaining.) That's why I really appreciate you took the time to show us how you debug CalorieCounting using J. (I've been using my xxd.) I also find Jan-Pieter's page organization super easy to follow. Many thanks to you all. Maurice On Sat, Aug 5, 2023 at 9:37 AM Henry Rich wrote: I agree. J can be used at different levels of sophistication and commitment. Any solution is welcome as long as it's clearly explained. This feature is aimed at obstacles to new use of J: * 'No one can read that!' Which is like saying no one can read music, an excuse for not trying. The remedy is to learn to read. Simple examples help. * 'My job doesn't use J.' Still, wouldn't you like a language that gets answers fast, perhaps for prototyping? * 'It's too different.' That's the real problem. We /do/ think differently in J. The pages here should show your state of mind as you code, thinking about the whole problem rather than atoms. These pages are not about showing off a brilliant solution, but about how you came to the solution. Henry Rich On 8/5/2023 3:06 AM, 'Rob Hodgkinson' via Programming wrote: Yes, of course, please contribute. Like Jan-Pieter you could provide a little background in the Preamble to explain. Your experience may be invaluable to people less experienced with J (or even more !!). On 5 Aug 2023, at 4:59 pm, Luke D wrote: I have a number of solutions for the easier PE problems I can add (I also have AoC solutions for various years). However, I have only been using J for 3 years, so am I invited to contribute? Best Regards, Luke De La Cruz On Fri, Aug 4, 2023 at 8:27 PM Henry Rich wrote: I have enjoyed reading your solutions. It's great to see the language used for somewhat realistic problems. Will those of you with Project Euler solutions step up and showcase your J? Just add to the ShareMyScreen page. Henry Rich On 8/4/2023 9:31 AM, Jan-Pieter Jacobs wrote: I've been working on putting my solutions for the first 5 AoC days at https://code.jsoftware.com/wiki/ShareMyScreen#by_Jan-Pieter_Jacobs Any feedback would be appreciated, and if I don't get any, I'll just assume I'm doing great job and continue as is ;). As a side note: does anyone have code for downloading inputs directly? I know it's possible, as there's a python package for that, but I wouldn't know how to get httpget to use the authentication cookie from the website. Jan-Pieter On Sat, 3 Jun 2023, 11:55 Henry Rich, wrote: Since these are personal explanations of the programming thought-process, I think it's proper that they be grouped by author within each subject. I will put my name on my AoC contributions. Jan-Pieter, you can create a section for yours. Project Euler is widely known and annotated solutions would be just the sort of thing I was looking for with this page. The annotation is what the page is about: if you have a one-line solution you should expect to take 20-80 lines of text explaining it and building it up with examples. Writing the answer up will take quite a bit longer than coming up with the solution! Henry Rich On 6/2/2023 6:51 PM, 'Viktor Grigorov' via Programming wrote: I'd agree that examples are great, e.g., Rosetta Code is a great compendium of programming language equiproblem solution comparisons. A comma-delimited listing of would be too much, as there aren't that many J active users, at least judging from the names I've seen past 2 years on the general and programming mailing list. Consider a table. Heading rows would be links to problems in ascending order from advent of code (or projecteuler.net, or leetcode, ...). Heading columns would be solution-contributing users' links (if such exist on the jwiki). Cell would be either inline code hidden in a summary tag (in HTML, or whatever wikis' equivalent of that is) or link to location of those users' solutions, prop
Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial
I agree with Luke. Henry Rich On 8/5/2023 5:12 AM, Luke D wrote: I suppose it is worth reminding everyone that only the first 100 PE problems can be shared. Because of this, I don't think spoilers are necessary. PE only asks that any discussion about said problems is done to instruct and not just give answers, which is the intention of ShareMyScreen. Best Regards, Luke De La Cruz On Sat, Aug 5, 2023 at 2:48 AM 'Mike Day' via Programming < programm...@jsoftware.com> wrote: Re Project Euler, if we put something up there, how do we ensure it's not too open to would-be solvers? Just place lots of SPOILER ALERTS in their/our way? Thanks Mike Sent from my iPad On 5 Aug 2023, at 02:27, Henry Rich wrote: I have enjoyed reading your solutions. It's great to see the language used for somewhat realistic problems. Will those of you with Project Euler solutions step up and showcase your J? Just add to the ShareMyScreen page. Henry Rich On 8/4/2023 9:31 AM, Jan-Pieter Jacobs wrote: I've been working on putting my solutions for the first 5 AoC days at https://code.jsoftware.com/wiki/ShareMyScreen#by_Jan-Pieter_Jacobs Any feedback would be appreciated, and if I don't get any, I'll just assume I'm doing great job and continue as is ;). As a side note: does anyone have code for downloading inputs directly? I know it's possible, as there's a python package for that, but I wouldn't know how to get httpget to use the authentication cookie from the website. Jan-Pieter On Sat, 3 Jun 2023, 11:55 Henry Rich, wrote: Since these are personal explanations of the programming thought-process, I think it's proper that they be grouped by author within each subject. I will put my name on my AoC contributions. Jan-Pieter, you can create a section for yours. Project Euler is widely known and annotated solutions would be just the sort of thing I was looking for with this page. The annotation is what the page is about: if you have a one-line solution you should expect to take 20-80 lines of text explaining it and building it up with examples. Writing the answer up will take quite a bit longer than coming up with the solution! Henry Rich On 6/2/2023 6:51 PM, 'Viktor Grigorov' via Programming wrote: I'd agree that examples are great, e.g., Rosetta Code is a great compendium of programming language equiproblem solution comparisons. A comma-delimited listing of would be too much, as there aren't that many J active users, at least judging from the names I've seen past 2 years on the general and programming mailing list. Consider a table. Heading rows would be links to problems in ascending order from advent of code (or projecteuler.net, or leetcode, ...). Heading columns would be solution-contributing users' links (if such exist on the jwiki). Cell would be either inline code hidden in a summary tag (in HTML, or whatever wikis' equivalent of that is) or link to location of those users' solutions, properly identified (id='...') to be more navigable to-and-fro san scrolling. Inlining would be hellish on rendition, so probably not. I can contribute 45 projecteuler not great one-liners for whatever that's worth. Jun 2, 2023, 22:32 by janpieter.jac...@gmail.com: Great initiative, Henry. I'm considering gradually adding my versions. How do you think it's best to structure this? One section per person with a list of pages for each problem, or put solutions of different persons close to each other? My solutions are still a work in progress, though; currently solving day 19. Cheers, Jan-Pieter On Wed, May 31, 2023 at 5:01 PM Henry Rich wrote: How do you convince someone that J is really different? Examples seem contrived. I am trying something new. I have used J to solve a suite of programming problems posed by an impartial source, to wit Advent of Code 2022. Tire-kickers can compare the J solutions against those in other languages. The pages are at https://code.jsoftware.com/wiki/ShareMyScreen . IF YOU ARE NEW TO J, you are the person I need to hear from. Where do I need to add explanatory material, or rewrite a section? IF YOU ARE AN OLD J HAND, consider adding your own programs. They can be from any source as long as you make the solution comprehensible to a novice. I know several users on this list solved the AoC2022 problems; alternative solution pages would be welcome. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/foru
Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial
I agree. J can be used at different levels of sophistication and commitment. Any solution is welcome as long as it's clearly explained. This feature is aimed at obstacles to new use of J: * 'No one can read that!' Which is like saying no one can read music, an excuse for not trying. The remedy is to learn to read. Simple examples help. * 'My job doesn't use J.' Still, wouldn't you like a language that gets answers fast, perhaps for prototyping? * 'It's too different.' That's the real problem. We /do/ think differently in J. The pages here should show your state of mind as you code, thinking about the whole problem rather than atoms. These pages are not about showing off a brilliant solution, but about how you came to the solution. Henry Rich On 8/5/2023 3:06 AM, 'Rob Hodgkinson' via Programming wrote: Yes, of course, please contribute. Like Jan-Pieter you could provide a little background in the Preamble to explain. Your experience may be invaluable to people less experienced with J (or even more !!). On 5 Aug 2023, at 4:59 pm, Luke D wrote: I have a number of solutions for the easier PE problems I can add (I also have AoC solutions for various years). However, I have only been using J for 3 years, so am I invited to contribute? Best Regards, Luke De La Cruz On Fri, Aug 4, 2023 at 8:27 PM Henry Rich wrote: I have enjoyed reading your solutions. It's great to see the language used for somewhat realistic problems. Will those of you with Project Euler solutions step up and showcase your J? Just add to the ShareMyScreen page. Henry Rich On 8/4/2023 9:31 AM, Jan-Pieter Jacobs wrote: I've been working on putting my solutions for the first 5 AoC days at https://code.jsoftware.com/wiki/ShareMyScreen#by_Jan-Pieter_Jacobs Any feedback would be appreciated, and if I don't get any, I'll just assume I'm doing great job and continue as is ;). As a side note: does anyone have code for downloading inputs directly? I know it's possible, as there's a python package for that, but I wouldn't know how to get httpget to use the authentication cookie from the website. Jan-Pieter On Sat, 3 Jun 2023, 11:55 Henry Rich, wrote: Since these are personal explanations of the programming thought-process, I think it's proper that they be grouped by author within each subject. I will put my name on my AoC contributions. Jan-Pieter, you can create a section for yours. Project Euler is widely known and annotated solutions would be just the sort of thing I was looking for with this page. The annotation is what the page is about: if you have a one-line solution you should expect to take 20-80 lines of text explaining it and building it up with examples. Writing the answer up will take quite a bit longer than coming up with the solution! Henry Rich On 6/2/2023 6:51 PM, 'Viktor Grigorov' via Programming wrote: I'd agree that examples are great, e.g., Rosetta Code is a great compendium of programming language equiproblem solution comparisons. A comma-delimited listing of would be too much, as there aren't that many J active users, at least judging from the names I've seen past 2 years on the general and programming mailing list. Consider a table. Heading rows would be links to problems in ascending order from advent of code (or projecteuler.net, or leetcode, ...). Heading columns would be solution-contributing users' links (if such exist on the jwiki). Cell would be either inline code hidden in a summary tag (in HTML, or whatever wikis' equivalent of that is) or link to location of those users' solutions, properly identified (id='...') to be more navigable to-and-fro san scrolling. Inlining would be hellish on rendition, so probably not. I can contribute 45 projecteuler not great one-liners for whatever that's worth. Jun 2, 2023, 22:32 by janpieter.jac...@gmail.com: Great initiative, Henry. I'm considering gradually adding my versions. How do you think it's best to structure this? One section per person with a list of pages for each problem, or put solutions of different persons close to each other? My solutions are still a work in progress, though; currently solving day 19. Cheers, Jan-Pieter On Wed, May 31, 2023 at 5:01 PM Henry Rich wrote: How do you convince someone that J is really different? Examples seem contrived. I am trying something new. I have used J to solve a suite of programming problems posed by an impartial source, to wit Advent of Code 2022. Tire-kickers can compare the J solutions against those in other languages. The pages are at https://code.jsoftware.com/wiki/ShareMyScreen . IF YOU ARE NEW TO J, you are the person I need to hear from. Where do I need to add explanatory material, or rewrite a section? IF YOU ARE AN OLD J HAND, consider adding your own programs. They can be from any source as long as you make the solution comprehensible to a novice. I know several users on this list solved the AoC2022 problems
Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial
I have enjoyed reading your solutions. It's great to see the language used for somewhat realistic problems. Will those of you with Project Euler solutions step up and showcase your J? Just add to the ShareMyScreen page. Henry Rich On 8/4/2023 9:31 AM, Jan-Pieter Jacobs wrote: I've been working on putting my solutions for the first 5 AoC days at https://code.jsoftware.com/wiki/ShareMyScreen#by_Jan-Pieter_Jacobs Any feedback would be appreciated, and if I don't get any, I'll just assume I'm doing great job and continue as is ;). As a side note: does anyone have code for downloading inputs directly? I know it's possible, as there's a python package for that, but I wouldn't know how to get httpget to use the authentication cookie from the website. Jan-Pieter On Sat, 3 Jun 2023, 11:55 Henry Rich, wrote: Since these are personal explanations of the programming thought-process, I think it's proper that they be grouped by author within each subject. I will put my name on my AoC contributions. Jan-Pieter, you can create a section for yours. Project Euler is widely known and annotated solutions would be just the sort of thing I was looking for with this page. The annotation is what the page is about: if you have a one-line solution you should expect to take 20-80 lines of text explaining it and building it up with examples. Writing the answer up will take quite a bit longer than coming up with the solution! Henry Rich On 6/2/2023 6:51 PM, 'Viktor Grigorov' via Programming wrote: I'd agree that examples are great, e.g., Rosetta Code is a great compendium of programming language equiproblem solution comparisons. A comma-delimited listing of would be too much, as there aren't that many J active users, at least judging from the names I've seen past 2 years on the general and programming mailing list. Consider a table. Heading rows would be links to problems in ascending order from advent of code (or projecteuler.net, or leetcode, ...). Heading columns would be solution-contributing users' links (if such exist on the jwiki). Cell would be either inline code hidden in a summary tag (in HTML, or whatever wikis' equivalent of that is) or link to location of those users' solutions, properly identified (id='...') to be more navigable to-and-fro san scrolling. Inlining would be hellish on rendition, so probably not. I can contribute 45 projecteuler not great one-liners for whatever that's worth. Jun 2, 2023, 22:32 by janpieter.jac...@gmail.com: Great initiative, Henry. I'm considering gradually adding my versions. How do you think it's best to structure this? One section per person with a list of pages for each problem, or put solutions of different persons close to each other? My solutions are still a work in progress, though; currently solving day 19. Cheers, Jan-Pieter On Wed, May 31, 2023 at 5:01 PM Henry Rich wrote: How do you convince someone that J is really different? Examples seem contrived. I am trying something new. I have used J to solve a suite of programming problems posed by an impartial source, to wit Advent of Code 2022. Tire-kickers can compare the J solutions against those in other languages. The pages are at https://code.jsoftware.com/wiki/ShareMyScreen . IF YOU ARE NEW TO J, you are the person I need to hear from. Where do I need to add explanatory material, or rewrite a section? IF YOU ARE AN OLD J HAND, consider adding your own programs. They can be from any source as long as you make the solution comprehensible to a novice. I know several users on this list solved the AoC2022 problems; alternative solution pages would be welcome. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Syntax Highlighting: Special Combinations
They are legion. Example: x -@:{`[`]} y uses special code only when y is floating point. Henry Rich On 7/31/2023 10:40 AM, Ak O wrote: Can you share examples where the form of an SC is satisfied, but the interpreter does not perform the SC routine? AO On Mon., Jul. 31, 2023, 06:39 Henry Rich, wrote: A special combination will always include a (possibly invisible) modifier, and is recognized when that modifier is executed (during parsing). For example, i.&1@:> is detected when @: is executed with its u= i.&1 and its v= > . The values of u and v are inspected. Seeing that they have the form for an SC, the interpreter alters the rouine-address from the normal handler for @:, to proceed instead to the code performing the SC. Henry Rich On 7/30/2023 10:13 PM, Ak O wrote: What system currently governs Syntax Highlighting in the editor? By example: If you start typing a number you get a certain colour. If you type a letter you get another colour. Also, how are Special Combinations currently triggered by the parser? AO. On Sun., Jul. 30, 2023, 11:51 Raul Miller, wrote: I see two possible ways to implement this sort of functionality. (A) Create a duplicate copy of J's parser, which would run in the highlighting environment, to identify regions corresponding to "special code", or (B) Update J itself to provide a "dry run" mechanism to identify these regions in a potential sentence (if and only if the sentence was valid, though maybe that could be relaxed to "has a valid suffix"). Neither task is trivial. Either approach would require creating a well-defined interface for this process. -- Raul On Sun, Jul 30, 2023 at 1:41 PM Hauke Rehr wrote: my 2 cents I’m quite satisfied with the highlight I get when writing J in Vim; and with the highlight I get when typesetting J in TeX with minted. Neither do custom handling of Special Combinations, though. IIRC, Michal rolled his own for his jprez stuff (editor part). @Michal: Did you consider highlighting SCs differently? Any thoughts? I’d be glad to have a visual indication that would let me learn to use them without always having to look them up (I still don’t grok even -:J). Hauke Am 30.07.23 um 19:17 schrieb Henry Rich: What a great idea! I know nothing about Syntax Highlighting but I would love to see it in the display. There will be a problem keeping the highlighting up to date with the evolving support for special combinations. Henry Rich On 7/30/2023 12:59 PM, Ak O wrote: Hi all, I hope you are all well. Two questions. 1. Is there a way to include Special Combinations in Syntax Highlighting? Meaning some visual indicator that an arrangement of Operators triggers a Special Combination. 2. What page should I be looking up to understand the significance of Syntax Highlights. I am not sure what exactly that is called. For example: Something(...) NB. Colour change to 'Something' Vs. Something (...) NB. No Colour changes to 'Something' Which page do I find that type of information? Thank you, AO. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Syntax Highlighting: Special Combinations
You are right about i.!.0. It is discussed in https://code.jsoftware.com/wiki/Vocabulary/IFamily but who has read that? You are also right that the datatypes matter. Highlighting near-misses would be great, if it could be doone. Henry Rich On 7/31/2023 4:18 AM, Jan-Pieter Jacobs wrote: In addition to the higlighting of correctly used special combinations, I think it would also be useful to highlight, or issue warnings for (as done for 9!:55) for near-misses, i.e. caused by phrases that could use a special combination, but miss it due to wrong or missing parentheses etc. My uneducated hunch is that datatypes on which the special combinations are executed are also important, but would only be available at execution time. Another type of phrases that might be nice to highlight is things like possibilities for speeding up by dropping tolerant comparison: While working on AoC, I recently had a case where using i.!.0 instead of i. for lookup of rows in a matrix sped up the program by more than 20x ! My two cents. Jan-Pieter On Mon, 31 Jul 2023, 05:27 Raul Miller, wrote: In the wiki, we have aka GeSHI. https://www.mediawiki.org/wiki/Extension:SyntaxHighlight https://github.com/GeSHi/geshi-1.0/blob/master/src/geshi/j.php In jqt, we're using QSyntaxHighlighter https://doc.qt.io/qt-5/qsyntaxhighlighter.html https://github.com/jsoftware/qtide/blob/master/lib/high/highj.cpp#L15 I think jhs uses CodeMirror. https://codemirror.net/5/doc/manual.html#modeapi https://github.com/jsoftware/ide_jhs/blob/master/js/codemirror/j/j.4.2.js I hope this helps, -- Raul On Sun, Jul 30, 2023 at 10:23 PM Ak O wrote: In the editor initially. My question about the wiki was if there was already an informational reference that might have had a term I was not thinking of. Working within a wiki page seems like it might be new question altogether. AO. On Sun., Jul. 30, 2023, 16:02 'Viktor Grigorov' via Programming, < programm...@jsoftware.com> wrote: My twopence: Worth confirming: did you mean syntax highlighting on wiki pages or for the various text editors? Can't speak for jQt IDE.The answer for both is 'yes', certainly for the simpler ones. Easier for the former, I reckon. Consider also: should special combinations receive one color, that of what they resolve to; or should they additionally be italicized, emboldened, or underlined? For my syntax highlighting code for kakoune, I'd considered indicating with straight and wavy underlines whether a verb train resolves to a hook or a fork. I'd decided against it to not add clutter. Jul 30, 2023, 20:00 by akin...@gmail.com: Hi all, I hope you are all well. Two questions. 1. Is there a way to include Special Combinations in Syntax Highlighting? Meaning some visual indicator that an arrangement of Operators triggers a Special Combination. 2. What page should I be looking up to understand the significance of Syntax Highlights. I am not sure what exactly that is called. For example: Something(...) NB. Colour change to 'Something' Vs. Something (...) NB. No Colour changes to 'Something' Which page do I find that type of information? Thank you, AO. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Syntax Highlighting: Special Combinations
A special combination will always include a (possibly invisible) modifier, and is recognized when that modifier is executed (during parsing). For example, i.&1@:> is detected when @: is executed with its u= i.&1 and its v= > . The values of u and v are inspected. Seeing that they have the form for an SC, the interpreter alters the routine-address from the normal handler for @:, to proceed instead to the code performing the SC. Henry Rich On 7/30/2023 10:13 PM, Ak O wrote: What system currently governs Syntax Highlighting in the editor? By example: If you start typing a number you get a certain colour. If you type a letter you get another colour. Also, how are Special Combinations currently triggered by the parser? AO. On Sun., Jul. 30, 2023, 11:51 Raul Miller, wrote: I see two possible ways to implement this sort of functionality. (A) Create a duplicate copy of J's parser, which would run in the highlighting environment, to identify regions corresponding to "special code", or (B) Update J itself to provide a "dry run" mechanism to identify these regions in a potential sentence (if and only if the sentence was valid, though maybe that could be relaxed to "has a valid suffix"). Neither task is trivial. Either approach would require creating a well-defined interface for this process. -- Raul On Sun, Jul 30, 2023 at 1:41 PM Hauke Rehr wrote: my 2 cents I’m quite satisfied with the highlight I get when writing J in Vim; and with the highlight I get when typesetting J in TeX with minted. Neither do custom handling of Special Combinations, though. IIRC, Michal rolled his own for his jprez stuff (editor part). @Michal: Did you consider highlighting SCs differently? Any thoughts? I’d be glad to have a visual indication that would let me learn to use them without always having to look them up (I still don’t grok even -:J). Hauke Am 30.07.23 um 19:17 schrieb Henry Rich: What a great idea! I know nothing about Syntax Highlighting but I would love to see it in the display. There will be a problem keeping the highlighting up to date with the evolving support for special combinations. Henry Rich On 7/30/2023 12:59 PM, Ak O wrote: Hi all, I hope you are all well. Two questions. 1. Is there a way to include Special Combinations in Syntax Highlighting? Meaning some visual indicator that an arrangement of Operators triggers a Special Combination. 2. What page should I be looking up to understand the significance of Syntax Highlights. I am not sure what exactly that is called. For example: Something(...) NB. Colour change to 'Something' Vs. Something (...) NB. No Colour changes to 'Something' Which page do I find that type of information? Thank you, AO. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- -- mail written using NEO neo-layout.org -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Syntax Highlighting: Special Combinations
I think the fork/hook idea is excellent, especially as an option. Is there a way in Jqt to find the match for () ? Henry Rich On 7/30/2023 6:02 PM, 'Viktor Grigorov' via Programming wrote: My twopence: Worth confirming: did you mean syntax highlighting on wiki pages or for the various text editors? Can't speak for jQt IDE.The answer for both is 'yes', certainly for the simpler ones. Easier for the former, I reckon. Consider also: should special combinations receive one color, that of what they resolve to; or should they additionally be italicized, emboldened, or underlined? For my syntax highlighting code for kakoune, I'd considered indicating with straight and wavy underlines whether a verb train resolves to a hook or a fork. I'd decided against it to not add clutter. Jul 30, 2023, 20:00 by akin...@gmail.com: Hi all, I hope you are all well. Two questions. 1. Is there a way to include Special Combinations in Syntax Highlighting? Meaning some visual indicator that an arrangement of Operators triggers a Special Combination. 2. What page should I be looking up to understand the significance of Syntax Highlights. I am not sure what exactly that is called. For example: Something(...) NB. Colour change to 'Something' Vs. Something (...) NB. No Colour changes to 'Something' Which page do I find that type of information? Thank you, AO. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] [jsoftware/jsource] Define value for `_3` (arctan) when argument is a complex number with infinity components (Issue #180)
I have just checked and JE already does treat _0. as negative zero: % _0. __ It is hard to keep -0 through a calculation. Whenever you add it to a nonnegative number it acts like 0. If all you do is multiply and divide you can keep the negative zero, with the exception that +-0 % +-0 gives +0. Henry Rich On 7/30/2023 3:26 PM, Henry Rich wrote: You have found an error, I think. We were /not/ using Kahan's formula and branch cuts. (Our version came from Abramowitz & Stegun) William Kahan is a mighty man. On his authority (and the sources you cited) I have changed to his formulas for arctanh/arctan. I have not checked his other 7 formulas. -0 was problematic. You can create a float -0 but I couldn't find a way to make that the real part of a complex value. m0 =. 1 % __ % m0 __ % +. m0 j. 0 NB. should be __ _ _ _ This was because (x j. y) did a complex multiply, which used addition, which wiped out the -0. I have now modified (x j. y) so that it avoids the multiplication when given real arguments. Now % +. m0 j. 0 __ _ That revealed the problem you point out in this post: _3 o. _1e_100 j. 1e10 _1.5708j1e_10 _3 o. m0 j. 1e10 1.5708j1e_10 I fixed that as well. Now _3 o. m0 j. 1e10 _1.5708j1e_10 I also fixed it so that if either component is large, the result is +-pi/2, avoiding the previous NaN errors. These fixes will go out either in the imminent next beta or the one after that. Perhaps we should take _0. to mean negative zero. I don't see a good reason not to. Henry Rich On 7/29/2023 7:05 PM, LdBeth wrote: Actually, the current J atan/atanh implementation ignores the sign of real part when the complex part goes infinity. While in Chez or CCL the sign of real component is use for the result: |> (atan 0.0+1e18i) 1.5707963267948966+0.0i > (atan -0.0+1e18i) -1.5707963267948966+0.0i | |_3 o. _1.0j_1e18 1.5708 _3 o. 1.0j_1e18 1.5708 | This also comes to the notorious signed zero problem. I know J does not differentiate pos zero and neg zero. There is really a design choice need to be made for the problem. — Reply to this email directly, view it on GitHub <https://github.com/jsoftware/jsource/issues/180#issuecomment-1656947906>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AEKVAJ2OFK2CG5GKBD7BKBDXSWJNNANCNFSM6AA2ZSCW2Q>. You are receiving this because you are subscribed to this thread.Message ID: -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Syntax Highlighting: Special Combinations
What a great idea! I know nothing about Syntax Highlighting but I would love to see it in the display. There will be a problem keeping the highlighting up to date with the evolving support for special combinations. Henry Rich On 7/30/2023 12:59 PM, Ak O wrote: Hi all, I hope you are all well. Two questions. 1. Is there a way to include Special Combinations in Syntax Highlighting? Meaning some visual indicator that an arrangement of Operators triggers a Special Combination. 2. What page should I be looking up to understand the significance of Syntax Highlights. I am not sure what exactly that is called. For example: Something(...) NB. Colour change to 'Something' Vs. Something (...) NB. No Colour changes to 'Something' Which page do I find that type of information? Thank you, AO. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Simulations
I agree that one or a few numeric array(s) without boxing is preferable. If each atom has the same number of forces it's certainly best. Boxing is to be avoided usually. If I remember aright from many years back, at the end of one highschool year I offered to teach J to a promising sophomore, one Marshall Lochbaum, the next year. To get a head start, he chose as his first (entirely untutored) summer project atomic collisions in varying numbers of dimensions. He showed up at the start of the semester with about 50 lines, which worked fine, showing the Maxwell-Boltzmann distribution (in 3 dimensions). All tacit code it was. You follow in broad footsteps. Henry Rich On 7/15/2023 9:15 AM, Raul Miller wrote: I think the approaches you described are fine. That said, another approach would be to think of your dataset as a table -- one row for each atom, with each column having different significance. coordinate x,y, z; velocity x,y,z; force x,y,z, So, if you had 42 atoms, your data would be a 42 by 9 matrix. Or, perhaps it would be better to distinguish x,y,z from coordinate/velocity/force (the 42 atom example being represented with a 42 by 3 by 3 array or perhaps more conveniently a 3 by 42 by 3 array). This last approach might have an implementation something like: do_step=: positions_update, velocities_update,: forces_update where each of the update verbs obtains the requisite information from its y argument. I hope this makes sense, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] t. experiments
Those numbers suggest that you are getting some use out of the hyperthreads, so you should keep using them. What is the u in u;._3? And what is your CPU model? I should have said, when you have created 3 worker threads you should split your job into 3+1=4 tasks. The master thread pitches in to run a task when all the worker threads are busy. hhr On 7/14/2023 7:21 AM, Clifford Reiter wrote: The array is periodically extended so the result of u;._3 is 512 by 512. Using 3 threads instead of 7 and t. on 512 three by 512 pieces takes 59 sec and J uses 10% of total cpu I'll try slicing 512 by 3 and 512 by m pieces later. Thanks for the comments, especially the insights into u;._3 ! On Thu, Jul 13, 2023 at 2:09 PM Henry Rich wrote: I'm surprised that the result is 512x512 when you use u;._3 on 512x512 argument. Do you pad after the operation? 1. How good the operation is for threading depends on the ratio of processing to reading arguments/writing results. The arguments start out in a different core's cache, and have to be transferred over the mesh to the core doing the processing. That takes dozens of cycles per cacheline transferred; whether that's a big number or not depends on how much work you have to do after the data arrives. I /THINK/ that each core has an interface to the mesh that runs at about the speed of the L3 cache on average. If anybody knows details about this, I hunger for them. 2. A logical processor is not a core. Two logical processors share cache/pipeline/execution units/memory interface, and only one can execute at a time. Again I can't find a good description of the details, but my guess is that a logical-processor switch occurs only on a pipeline break, i. e. a mispredicted branch. For sloppy C code with lots of conditionals, enough cycles are lost to pipeline breaks that it's worthwhile to have a hyperthread waiting to use them; but JE is coded with especial care to minimize the number of mispredicted branches. A single thread of JE will usually keep a core busy, I reckon. We recommend creating one thread per /core/, not per /logical processor/. Some applications can perhaps benefit from more threads than cores, but it doesn't surprise me that yours doesn't. 3. u;._3 was lovingly coded to minimize data movement for image processing. Consider a 3x3 convolution moving across a 5x5 argument. I start by copying the first 5x3 section: abc fgh klm pqr uvw Using a virtual argument, I execute u on these 3 3x3 cells (a-m, f-r, k-w) without moving any data. After going all the way down the column, I copy in the next column, overwriting the first column offset down one row: bc dgh ilm nqr svw x by simply advancing the array pointer one column, without moving any data, this is bcd ghi lmn qrs vwx and again I can use a virtual argument to process all the cells (b-n, g-s, l-x) without moving any data. The bottom line is that only a single copy of the input argument is made. What I'm saying is that u;._3 is very cache-friendly which might tend to reduce the gain from multithreading. It would be interesting to see how much better 7 worker threads are than 3. Henry Rich On 7/13/2023 1:26 PM, Clifford Reiter wrote: Hi, I thought I would experiment with t. I choose an "image" processing problem on a 512 by 512 array. Local (complex) processing occurs on 3 by 3 cells (u;._3) which results in a 512 by 512 array. That process is iterated (^:_), here around 150 times. So I thought this might be a good place to look for a speedup using t. 7 threads were created as per recommendation: {{0 T. 0}}^:] _1+{.8 T. '' time (sec, via 6!:2) on the left below. 113 with no t. 41with t. applied on 512 arrays of size 3 by 512 at each iteration 41 with t. applied to 7 nearly equal m by 512 blocks at each iteration 39 with t. applied to 14 nearly equal m by 512 blocks at each iteration I'm not unhappy with an almost 3x gain, but I am wondering if this is a bad problem for t. ? Also, when not using t., task manager shows J using about 3.8%, with t., it shows J using about 21%, other things are in the low single digits. I am surprised that I can't peg the cpu's near 100% . (4 cores, 8 logical processors, windows, J9.5 beta 4). Just sharing my experience and welcoming any comments. Best, Cliff -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] If, else on each element of an array
I was just making the point that the verb must return an array of results. < does not and that fails before the type of the result enters into the matter. 0: would give the same error. Henry Rich On 7/13/2023 6:10 PM, Raul Miller wrote: +: is double, < is box (which in this example would throw a type error). Other than that, ... using @. seems to be the way to go. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] If, else on each element of an array
+:`*:@.(1:) i. 20 NB. square the primes, double the nonprimes 0 2 4 9 8 25 12 49 16 18 20 121 24 169 28 30 32 289 36 361 The rank of the result of the selector verb (1:) implies the cell-size to be given to the verbs. For large arguments the cells to be fed into each verb are collected into an array, so the verb must be able to handle such an array of argument cells: <`*:@.(1:) i. 20 NB. square the primes, double the nonprimes |rank error, executing monad (<`*:)@.(1:) |each gerund must return a result whose shape agrees with its inputs | <`*:@.(1:)i.20 < was passed an array of cells, but it didn't return a result for each cell. Hey, you did say 'efficiently'. Henry Rich On 7/13/2023 5:50 PM, Marcin Żołek wrote: Hello, I need to define a function that will execute function f on the elements of an input array that meet a certain condition, and execute function g on the other elements as in the following code in C. How to do this efficiently in J? for (i = 0; i < N; i++) { if (condition(input[i])) { output[i] = f(input[i]); } else { output[i] = g(input[i]); } } Martin -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] t. experiments
I'm surprised that the result is 512x512 when you use u;._3 on 512x512 argument. Do you pad after the operation? 1. How good the operation is for threading depends on the ratio of processing to reading arguments/writing results. The arguments start out in a different core's cache, and have to be transferred over the mesh to the core doing the processing. That takes dozens of cycles per cacheline transferred; whether that's a big number or not depends on how much work you have to do after the data arrives. I /THINK/ that each core has an interface to the mesh that runs at about the speed of the L3 cache on average. If anybody knows details about this, I hunger for them. 2. A logical processor is not a core. Two logical processors share cache/pipeline/execution units/memory interface, and only one can execute at a time. Again I can't find a good description of the details, but my guess is that a logical-processor switch occurs only on a pipeline break, i. e. a mispredicted branch. For sloppy C code with lots of conditionals, enough cycles are lost to pipeline breaks that it's worthwhile to have a hyperthread waiting to use them; but JE is coded with especial care to minimize the number of mispredicted branches. A single thread of JE will usually keep a core busy, I reckon. We recommend creating one thread per /core/, not per /logical processor/. Some applications can perhaps benefit from more threads than cores, but it doesn't surprise me that yours doesn't. 3. u;._3 was lovingly coded to minimize data movement for image processing. Consider a 3x3 convolution moving across a 5x5 argument. I start by copying the first 5x3 section: abc fgh klm pqr uvw Using a virtual argument, I execute u on these 3 3x3 cells (a-m, f-r, k-w) without moving any data. After going all the way down the column, I copy in the next column, overwriting the first column offset down one row: bc dgh ilm nqr svw x by simply advancing the array pointer one column, without moving any data, this is bcd ghi lmn qrs vwx and again I can use a virtual argument to process all the cells (b-n, g-s, l-x) without moving any data. The bottom line is that only a single copy of the input argument is made. What I'm saying is that u;._3 is very cache-friendly which might tend to reduce the gain from multithreading. It would be interesting to see how much better 7 worker threads are than 3. Henry Rich On 7/13/2023 1:26 PM, Clifford Reiter wrote: Hi, I thought I would experiment with t. I choose an "image" processing problem on a 512 by 512 array. Local (complex) processing occurs on 3 by 3 cells (u;._3) which results in a 512 by 512 array. That process is iterated (^:_), here around 150 times. So I thought this might be a good place to look for a speedup using t. 7 threads were created as per recommendation: {{0 T. 0}}^:] _1+{.8 T. '' time (sec, via 6!:2) on the left below. 113 with no t. 41with t. applied on 512 arrays of size 3 by 512 at each iteration 41 with t. applied to 7 nearly equal m by 512 blocks at each iteration 39 with t. applied to 14 nearly equal m by 512 blocks at each iteration I'm not unhappy with an almost 3x gain, but I am wondering if this is a bad problem for t. ? Also, when not using t., task manager shows J using about 3.8%, with t., it shows J using about 21%, other things are in the low single digits. I am surprised that I can't peg the cpu's near 100% . (4 cores, 8 logical processors, windows, J9.5 beta 4). Just sharing my experience and welcoming any comments. Best, Cliff -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Fwd: Adverb in parsing table
Look at Vocabulary/Parsing in the wiki. Execution of an adverb produces an anonymous entity, usually a verb. Henry Rich On Sat, Jun 10, 2023, 10:40 PM Raul Miller wrote: > Adverbs are never dyadic. Nor are they monadic in the sense that verbs > are monadic. (An adverb takes a single left argument, a monadic verb > takes a single right argument.) > > If the result of the adverb is a verb (which is the case for built-in > adverbs, and many user defined adverbs), the resulting verb will carry > up to two definitions -- a monadic definition and a dyadic definition. > Which definition gets used depends on how that verb is used. If the > verb is used in a context where it doesn't have a definition, you get > an error. > > I hope this makes sense, > > -- > Raul > > On Sat, Jun 10, 2023 at 5:36 PM Raoul Schorer > wrote: > > > > Hello, > > > > When an adverb is executed, it should follow line 3 of the parsing table > ( > > https://www.jsoftware.com/help/jforc/parsing_and_execution_ii.htm ). > But: > > > > > >- How does the interpreter know if it should execute the 'monadic' vs. > >'dyadic' adverb, e.g. 'infix' or 'table' in the case of '/' ? > >- And how does the interpreter infer the definite resulting > >part-of-speech? Is there a check testing whether the result of the > adverb > >application is a procedure, and if so its arity? > > > > > > The documentation states that "In all cases the word replacing the > fragment > > has a definite part of speech, and if it is a verb, a definite rank". How > > this is achieved for all cases with an adverb is non-obvious to me... > > > > Thanks! > > Raoul > > -- > > For information about J forums see http://www.jsoftware.com/forums.htm > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Minor Nitpick
Your supposition is not quite right. Characters are not in the domain of arithmetic operations and produce domain error. HOWEVER, when a verb that is executed on an empty argument is executed on a cell of fill, and the execution on the fill cell results in error, the error is ignored and execution proceeds as if the execution had returned 0. Henry Rich On Fri, Jun 9, 2023, 5:33 AM Mike Duvos wrote: > Hi, > > Isn’t it a convention that a null character vector behaves the same as a > null numeric vector in an arithmetic context? > > I get the following results in J > > $$ 2 2 #: i. 0 > > 2 > > $$ 2 2 #: '' > > 1 > > > Yet in APL, of course… > > > ⍴⍴2 2 ⊤'' > > 2 > > ⍴⍴2 2 ⊤⍳0 > > 2 > > > > This seems somewhat unhelpful. > > > Regards, > > Mike > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Advent of Code 2022 in J, as a tutorial
Since these are personal explanations of the programming thought-process, I think it's proper that they be grouped by author within each subject. I will put my name on my AoC contributions. Jan-Pieter, you can create a section for yours. Project Euler is widely known and annotated solutions would be just the sort of thing I was looking for with this page. The annotation is what the page is about: if you have a one-line solution you should expect to take 20-80 lines of text explaining it and building it up with examples. Writing the answer up will take quite a bit longer than coming up with the solution! Henry Rich On 6/2/2023 6:51 PM, 'Viktor Grigorov' via Programming wrote: I'd agree that examples are great, e.g., Rosetta Code is a great compendium of programming language equiproblem solution comparisons. A comma-delimited listing of would be too much, as there aren't that many J active users, at least judging from the names I've seen past 2 years on the general and programming mailing list. Consider a table. Heading rows would be links to problems in ascending order from advent of code (or projecteuler.net, or leetcode, ...). Heading columns would be solution-contributing users' links (if such exist on the jwiki). Cell would be either inline code hidden in a summary tag (in HTML, or whatever wikis' equivalent of that is) or link to location of those users' solutions, properly identified (id='...') to be more navigable to-and-fro san scrolling. Inlining would be hellish on rendition, so probably not. I can contribute 45 projecteuler not great one-liners for whatever that's worth. Jun 2, 2023, 22:32 by janpieter.jac...@gmail.com: Great initiative, Henry. I'm considering gradually adding my versions. How do you think it's best to structure this? One section per person with a list of pages for each problem, or put solutions of different persons close to each other? My solutions are still a work in progress, though; currently solving day 19. Cheers, Jan-Pieter On Wed, May 31, 2023 at 5:01 PM Henry Rich wrote: How do you convince someone that J is really different? Examples seem contrived. I am trying something new. I have used J to solve a suite of programming problems posed by an impartial source, to wit Advent of Code 2022. Tire-kickers can compare the J solutions against those in other languages. The pages are at https://code.jsoftware.com/wiki/ShareMyScreen . IF YOU ARE NEW TO J, you are the person I need to hear from. Where do I need to add explanatory material, or rewrite a section? IF YOU ARE AN OLD J HAND, consider adding your own programs. They can be from any source as long as you make the solution comprehensible to a novice. I know several users on this list solved the AoC2022 problems; alternative solution pages would be welcome. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
[Jprogramming] Advent of Code 2022 in J, as a tutorial
How do you convince someone that J is really different? Examples seem contrived. I am trying something new. I have used J to solve a suite of programming problems posed by an impartial source, to wit Advent of Code 2022. Tire-kickers can compare the J solutions against those in other languages. The pages are at https://code.jsoftware.com/wiki/ShareMyScreen . IF YOU ARE NEW TO J, you are the person I need to hear from. Where do I need to add explanatory material, or rewrite a section? IF YOU ARE AN OLD J HAND, consider adding your own programs. They can be from any source as long as you make the solution comprehensible to a novice. I know several users on this list solved the AoC2022 problems; alternative solution pages would be welcome. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Bivalent verb query
See item 1 under 'Common Uses' in https://code.jsoftware.com/wiki/Vocabulary/dollarco Henry Rich On 5/19/2023 9:44 AM, 'Rob B' via Programming wrote: Apologies I thought I had already sent this message but it got lost…. Thanks Henry, nuvoc $: does say 'tacit' but I missed that, doh. Is there any way to achieve what I was trying to do, ie define the dyad in terms of the monad? I am on iPadOS 15. J701 gives stack error but J903 crashes. Thanks, Rob. On 15 May 2023, at 13:49, Henry Rich wrote: Yes. $: applies only to tacit programs or tacit components of sentences. The simplest way to get a stack error is $: 0 (but if you can make it crash in 9.4 or later, please report how you did it and what your JVERSION is) $: means 'execute the verb phrase I was contained in'. $: by itself means 'execute myself' with nothing to stop the recursion. $: is difficult to define in words. https://code.jsoftware.com/wiki/Vocabulary/dollarco under More Information is the best I can do. Henry Rich On 5/15/2023 8:36 AM, Brian Schott wrote: Reading in Nuvoc I see the following comment. Perhaps, it pertains. 3. In no case does $: refer to a larger unit than the sentence it appears in, for example an explicit definition in which it appears. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Bivalent verb query
If $: appears in a tacit verb, its value is that entire verb. It's when $: appears in a phrase in a sentence that it gets more complicated. Henry Rich On 5/19/2023 7:54 AM, David Lambert wrote: Self reference applies to the verb in which it is defined. This seems to be the entire tacit verb. https://code.jsoftware.com/wiki/Vocabulary/dollarco $ ijconsole a=: i.4 ff=: 3 : 0 +/ y : ff x,:y ) ff a 6 666 ff a 666 667 668 669 ff_tacit=: +/ : ([: $: ,:) ff_tacit a 6 666 ff_tacit a 666 667 668 669 Date: Mon, 15 May 2023 11:52:38 +0100 From: "'Rob B' via Programming" To: J Programming Subject: [Jprogramming] Bivalent verb query Message-ID: Content-Type: text/plain; charset=us-ascii Could someone explain what I've misunderstood here please? a=: i.4 ff=: 3 : 0 +/ y : $: x,:y ) ff a,:a NB. works a ff a NB. STACK ERROR or crash Thanks, Rob -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Bivalent verb query
Yes. $: applies only to tacit programs or tacit components of sentences. The simplest way to get a stack error is $: 0 (but if you can make it crash in 9.4 or later, please report how you did it and what your JVERSION is) $: means 'execute the verb phrase I was contained in'. $: by itself means 'execute myself' with nothing to stop the recursion. $: is difficult to define in words. https://code.jsoftware.com/wiki/Vocabulary/dollarco under More Information is the best I can do. Henry Rich On 5/15/2023 8:36 AM, Brian Schott wrote: Reading in Nuvoc I see the following comment. Perhaps, it pertains. 3. In no case does $: refer to a larger unit than the sentence it appears in, for example an explicit definition in which it appears. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Search
You can't beat a horse with no horse. What name do you suggest? Henry Rich On 5/9/2023 4:56 PM, Richard Donovan wrote: One of the most frustrating things about J is its name! For example, on Stack Exchange code review it seems impossible to search for any J articles, comments, code snippets etc. and I could suggest that rather than bother about whether to call the latest version J4, J904 etc which is trivial, you do something really useful such as change the name of the language to something sensible that can be searched upon. I know that in the past radical changes have been made to J eg changing x. and y. to x and y and I also know that a change of name would take a while to filter through but I do feel that eventually this change would have incredible benefits, similar to the recent long overdue introduction of sensible error messages which has been a real boon to me! Richard Donovan -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Crash on assignment
Fixed for next release/beta. The error was in formatting a message when the assignment failed because the value could not be opened. Only multiple assignment was affected. Thanks for the very clear report. Henry Rich On 4/20/2023 8:44 PM, Gilles Kirouac wrote: Say I have ]d=: _2 ]\ 'q1';'19.4';'q2';'878.34000';'q3';'200.3634' +--+-+ |q1|19.4 | +--+-+ |q2|878.34000| +--+-+ |q3|200.3634 | +--+-+ (]`(". each) "0) d +--+---+ |q1|19.4 | +--+---+ |q2|878.34 | +--+---+ |q3|200.363| +--+---+ The following will crash J: 'a b c'=: (]`(". each) "0) d JVERSION Engine: j9.4.2/j64/windows Build: commercial/2023-04-10T01:23:07/clang-15-0-7/SLEEF=1 Library: 9.4.21 Qt IDE: 2.0.3/6.2.4(6.2.4) Platform: Win 64 Installer: j9.4 install InstallPath: c:/users/mouton/j9.4 Contact: www.jsoftware.com ~ Gilles -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Problem with integer arithmetic
In the next beta u m. n means 'u(mod n)' and will work for + - * % ^ . %. coming soon. The only specials I see with m&| are m&|@^ and m&|@(n&^) which can be replaced by [n] (^ m. m) y. Example: 5 % m. 7 (9) gives 5 *(mod 7) (inverse of 9(mod 7)) Henry Rich On 4/17/2023 2:07 PM, 'Michael Day' via Programming wrote: u m. n ? I thought m. disappeared many versions ago, along with x. y. etc ! Could you provide an example? And is m&|@u deprecated for other verbs u ? Float results would be helpful. Presumably an array would be returned as float if at least one element needed to float, as usual. Thanks again, Mike On 16/04/2023 17:15, Henry Rich wrote: I think I have figured out a way to return float when the result has been made inaccurate. We had no choice about m&|@^ for negative y: the behavior of that is defined by the language, and it isn't modular. u m. n is a much cleaner solution, and faster. m&|@^ is deprecated. Henry Rich On Sun, Apr 16, 2023, 11:51 AM 'Michael Day' via Programming < programm...@jsoftware.com> wrote: Thanks for this and your previous comment re (-:<.@*<:) I'm afraid I've only just noticed this later reply in my J mail folder. I was going to grumble about x!y remaining integer even when the value might be wrong. Perhaps you or others might think of a suitable warning comment in NuVoc about dyadic ! . 2!y could perhaps be treated as special case, being a triangular number, y(y+1)/2 where one could right shift whichever of y, y+1 is even, but presumably that would involve too much overhead. Caveat Calculator, I suppose. BTW, I see you've decided against implementing x m&|@^ y for negative integer y, integer x, and extended m. (Though I don't remember m needing to be extended in earlier discussions!) A pity, but it's been useful to learn that the idiom is well supported for positive y. Cheers, Mike On 14/04/2023 14:22, Henry Rich wrote: As (x!y) is coded, the calculation is done in floating-point and then converted to integer if the result will fit. Loss of significance during the calculation will make the result inaccurate. I think it's a JE error to return an integer value when that value might be wrong. Unfortunately, the way the internal interfaces are, it's difficult to leave the value as floating-point, so you cannot use the fact that an integer was returned as a guarantee of accuracy. Henry Rich On 4/13/2023 11:34 AM, 'Michael Day' via Programming wrote: Yet again I found myself resorting to Pari GP for a calculation; my J function had been giving correct answers to a problem for lowish inputs, but apparently gave up at some stage for higher values; I then coded the calculation in Pari GP which gave the same results for low inputs, but diverged from J at the business end. Looking for inconsistencies between the two functions, the divergence seems to appear around this case: m =. 134235395 2^.m NB. plenty of room for multiplication in 64-bits??? 27.0002 2!m 9009570568285316 datatype 2!m integer (-:<.@*<:)m 9009570568285316 ((*<:)m)<.@%2 9009570568285315 _1 (33 b.) (*<:)m 9009570568285315 datatype (*<:)m integer So - why am I getting 2!m returned as integer but wrong? If there's overflow, why isn't it a float? Why does (-:<.@*<:)m return the wrong integer when ((*<:)m)<.@%2 yields the correct integer? This was in J.04, Engine: j9.4.2/j64avx2/windows Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1 I haven't checked behaviour in earlier releases. I didn't try extended integers for this problem. Thanks, Mike -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Problem with integer arithmetic
I think I have figured out a way to return float when the result has been made inaccurate. We had no choice about m&|@^ for negative y: the behavior of that is defined by the language, and it isn't modular. u m. n is a much cleaner solution, and faster. m&|@^ is deprecated. Henry Rich On Sun, Apr 16, 2023, 11:51 AM 'Michael Day' via Programming < programm...@jsoftware.com> wrote: > Thanks for this and your previous comment re (-:<.@*<:) > I'm afraid I've only just noticed this later reply in my J mail folder. > > I was going to grumble about x!y remaining integer even when the value > might be wrong. > Perhaps you or others might think of a suitable warning comment in NuVoc > about dyadic ! . > 2!y could perhaps be treated as special case, being a triangular > number, y(y+1)/2 where > one could right shift whichever of y, y+1 is even, but presumably that > would involve too > much overhead. Caveat Calculator, I suppose. > > BTW, I see you've decided against implementing x m&|@^ y for negative > integer y, integer x, > and extended m. (Though I don't remember m needing to be extended in > earlier discussions!) > A pity, but it's been useful to learn that the idiom is well supported > for positive y. > > Cheers, > > Mike > > On 14/04/2023 14:22, Henry Rich wrote: > > As (x!y) is coded, the calculation is done in floating-point and then > > converted to integer if the result will fit. Loss of significance > > during the calculation will make the result inaccurate. > > > > I think it's a JE error to return an integer value when that value > > might be wrong. Unfortunately, the way the internal interfaces are, > > it's difficult to leave the value as floating-point, so you cannot use > > the fact that an integer was returned as a guarantee of accuracy. > > > > Henry Rich > > > > On 4/13/2023 11:34 AM, 'Michael Day' via Programming wrote: > >> Yet again I found myself resorting to Pari GP for a calculation; my > >> J function had been giving > >> correct answers to a problem for lowish inputs, but apparently gave > >> up at some stage for > >> higher values; I then coded the calculation in Pari GP which gave > >> the same results for low > >> inputs, but diverged from J at the business end. > >> > >> Looking for inconsistencies between the two functions, the > >> divergence seems to appear > >> around this case: > >> > >> m =. 134235395 > >>2^.m NB. plenty of room for multiplication in 64-bits??? > >> 27.0002 > >> > >>2!m > >> 9009570568285316 > >>datatype 2!m > >> integer > >> > >>(-:<.@*<:)m > >> 9009570568285316 > >>((*<:)m)<.@%2 > >> 9009570568285315 > >>_1 (33 b.) (*<:)m > >> 9009570568285315 > >> > >>datatype (*<:)m > >> integer > >> > >> So - why am I getting 2!m returned as integer but wrong? If there's > >> overflow, > >> why isn't it a float? Why does(-:<.@*<:)m return the wrong > >> integer when > >>((*<:)m)<.@%2 yields the correct integer? > >> > >> This was in J.04, > >> Engine: j9.4.2/j64avx2/windows > >> Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1 > >> > >> I haven't checked behaviour in earlier releases. I didn't try > >> extended integers > >> for this problem. > >> > >> Thanks, > >> > >> Mike > >> > >> > >> > >> -- > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > -- > > For information about J forums see http://www.jsoftware.com/forums.htm > > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] docs for 11!:n (JWd)?
The info you are talking about at the end of your message is the block header. I can tell you all about that (so can Raul) but I am away from my machine until Monday. Look at jtype.h in the J source and find the definition of AD. Henry Rich On Sat, Apr 15, 2023, 6:36 PM Michal Wallace wrote: > Hrm. That does help a little bit. There's definitely still something called > JWd defined in JLib. > > Here is what I know so far: > (actually more than when I started typing this, so... I'll probably move > this to the wiki at some point.) > > When you write a J frontend, you have to call a function called JSM > (session manager) > and you pass in the addresses of four callback functions that your frontend > implements: > >JWr -> session calls this to output to whatever "terminal" you set up >JWd -> this window driver thing. >JRd -> session calls this when it needs to read a line of input >??? -> something reserved for future use? > > JWd does still seem to be hooked up to 11!:x (weird to see that called x > instead of n!) > > The signature looks like this: > > int _stdcall Jwd(JS jt, int x, A parg, A* pres, C* loc); > -- https://github.com/jsoftware/jsource/blob/master/jsrc/jlib.h#L111 > > The arguments seem to be: > > jt -> address of j session object > x -> the 'n' in 11!:n > parg -> the y argument to (11!n) (a pointer to a J array) > pres -> the result array (you modify this to put your return value here) > loc -> a locale name (?) > > There is an example J frontend here: > > https://github.com/jsoftware/jsource/blob/master/jsrc/jfex.c > > It has this comment for its implementation of Jwd (which is missing the loc > parameter): > > // J calls for 11!:x y - demonstrates all features of jwdw and jwdp > // pa is y and result array (if any) is returned in pz > // return pz > // 0 - MTM i.0 0 > // -1 A- A result > // -2 A- A is pairs of null terminated strings for event table > // n - EVDOMAIN etc > > > The 'parg' argument has the following fields, which I am expecting to match > the structure defined here: > >https://www.jsoftware.com/ioj/iojNoun.htm > > k -> "offset of ravel with respect to byte 0 of the array" > f -> a flag of some sort > m -> "maximum number of bytes in ravel" > t -> the type > c -> reference count > n -> the length of the data > r -> rank > s -> pointers to shape and value > > My implementation of Jwd just prints out the arguments... > >JWd(x:2000, a:[k: 64 f: 0 m: 117321808 t: 2 c: $8001 n: 5 r: > $BAADF00D062E0001]) > > I guess really my main problem is I don't understand how to interpret the > "rank" and "reference count" fields. > I'd expect both of these to be small positive integers, like what I see in > the ioj. > > Without the rank, I don't know how to parse the shape and value. > > Hrm. I guess technically I know from the docs that all (11!:n) are rank 1, > so maybe I can just ignore that field? > > I will investigate further. > > > On Sat, Apr 15, 2023 at 5:01 PM Raul Miller wrote: > > > Jwd sounds like version 6 of J. This predates Jqt. > > > > There's some docs at > > > https://www.jsoftware.com/docs/help602/user/win_driver_cmd_ref_overview.htm > > > > I hope this helps, > > > > -- > > Raul > > > > On Sat, Apr 15, 2023 at 4:57 PM Michal Wallace > > > wrote: > > > > > > Hey all, > > > > > > I've been working on JPrez again -- a console-based presentation tool > > > that can record and play back interactions with a J REPL. > > > > > > It also lets you specify text to be recorded for voice overs to narrate > > the > > > interaction (for making videos), and over the past week I've embedded > > > JPrez inside a windows binary that looks like a normal text console but > > > can peek inside JPrez and actually let me record and play audio for > > > the individual voice over lines. > > > > > > However, right now I'm doing everything from the host application. It > > polls > > > Jprez to see what's on the screen and what the current line of text is > > > (jprez suggests a filename for a corresponding wav file). > > > > > > That all works fine for recording one line at a time, but if I want to > > > actually > > > play the presentation, I'd much rather have J drive the interaction. > > > > > > I basically already have a J front end, but I don't know what t
Re: [Jprogramming] Problem with integer arithmetic
As (x!y) is coded, the calculation is done in floating-point and then converted to integer if the result will fit. Loss of significance during the calculation will make the result inaccurate. I think it's a JE error to return an integer value when that value might be wrong. Unfortunately, the way the internal interfaces are, it's difficult to leave the value as floating-point, so you cannot use the fact that an integer was returned as a guarantee of accuracy. Henry Rich On 4/13/2023 11:34 AM, 'Michael Day' via Programming wrote: Yet again I found myself resorting to Pari GP for a calculation; my J function had been giving correct answers to a problem for lowish inputs, but apparently gave up at some stage for higher values; I then coded the calculation in Pari GP which gave the same results for low inputs, but diverged from J at the business end. Looking for inconsistencies between the two functions, the divergence seems to appear around this case: m =. 134235395 2^.m NB. plenty of room for multiplication in 64-bits??? 27.0002 2!m 9009570568285316 datatype 2!m integer (-:<.@*<:)m 9009570568285316 ((*<:)m)<.@%2 9009570568285315 _1 (33 b.) (*<:)m 9009570568285315 datatype (*<:)m integer So - why am I getting 2!m returned as integer but wrong? If there's overflow, why isn't it a float? Why does (-:<.@*<:)m return the wrong integer when ((*<:)m)<.@%2 yields the correct integer? This was in J.04, Engine: j9.4.2/j64avx2/windows Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1 I haven't checked behaviour in earlier releases. I didn't try extended integers for this problem. Thanks, Mike -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Problem with integer arithmetic
You don't have 64 bits - you have 53 because you have gone into floating-point. (-:<.@*<:)m gives 9009570568285316 because the operation is promoted to floating-point when you divide, and it looks like you get roundoff in the multiply. Multiplying first is better, but you are still liable to get roundoff, because you are at the limit of the IEEE-754 mantissa. These numbers are just big enough that you need to be using extended integers if you want accurate results. Henry Rich On 4/13/2023 11:34 AM, 'Michael Day' via Programming wrote: Yet again I found myself resorting to Pari GP for a calculation; my J function had been giving correct answers to a problem for lowish inputs, but apparently gave up at some stage for higher values; I then coded the calculation in Pari GP which gave the same results for low inputs, but diverged from J at the business end. Looking for inconsistencies between the two functions, the divergence seems to appear around this case: m =. 134235395 2^.m NB. plenty of room for multiplication in 64-bits??? 27.0002 2!m 9009570568285316 datatype 2!m integer (-:<.@*<:)m 9009570568285316 ((*<:)m)<.@%2 9009570568285315 _1 (33 b.) (*<:)m 9009570568285315 datatype (*<:)m integer So - why am I getting 2!m returned as integer but wrong? If there's overflow, why isn't it a float? Why does (-:<.@*<:)m return the wrong integer when ((*<:)m)<.@%2 yields the correct integer? This was in J.04, Engine: j9.4.2/j64avx2/windows Build: commercial/2023-04-10T01:19:53/clang-15-0-7/SLEEF=1 I haven't checked behaviour in earlier releases. I didn't try extended integers for this problem. Thanks, Mike -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] kadane algorithm vs brute force timing and memory
(u/\. y) is defined as operating on successive suffixes, making it apparently O(n^2), but the implementation runs right to left in (n-1) applications of u. The result of each suffix is fed into the next-larger suffix. (u/\ y), OTOH, runs in O(n^2) time unless u is known to be associative. Henry Rich On 4/7/2023 3:09 AM, Thomas McGuire wrote: In my haste to produce an email after finally figuring out how Pepe’s elegant J implementation of the maximal sum of the subsequences worked ,I can see how you might interpret this as I was disappointed in the implementation as not being “pure” kadane. I meant only to classify the implementation so that the CPU times I was recording made sense From the perspective of big O analysis. Pure kadane is O(n). Where Pepe’s algorithm is being applied to a list (of length n) of lists of varying length 1..n, The operation performed 1+1+2+…+n-1 times. Which places it about O(n^2) though it’s been a while since I have done any algorithm analysis. In terms of a J implementation of the broader category of maximal sum of the subsequences of a list of numbers, Pepe’s algorithm is fantastic. From the perspective of my tutorial it is an incredibly insightful jump from the naive brute force implementations I had used. It is such a concise J implementation that highlights a significant portion of J’s advanced techniques. I intend on adding it to my tutorial I just hope I can explain it well enough to make it accessible to my target audience. On Apr 6, 2023, at 10:55 PM, Henry Rich wrote: I think that when you say Pepe's code is not the Kadane algorithm you are conflating algorithm and implementation. Kadane's idea is that (1) at each new prospective starting point for the maximal sequence, you have the option of starting at 0 or the previous best total; (2) every position is a prospective ending point. Pepe's algorithm follows these observations. The usual implementations keep two values through the loop: (a) the maximum value found on sequences that have ended; (b) the current total on sequences that the new value may add onto. Well, that's one way to do it. Another is to produce (a) as an intermediate result for each possible ending position, and then at the end see which of those values is the largest. That's what Pepe did. I approve his decision, since keeping two values through the scan would require ponderous indexing operations. This is the sort of implementation decision that surprises users of compiled languages. Pepe's implementation in no way changes the algorithm. It's merely a reordering of when comparisons are made. Pepe's algorithm is O(n), just as the usual algorithms are. As I tried to explain above the ([ >. +)/ is O(n) but when used on suffixes with the ‘\.’ operator it becomes O(n^2). the kadane”0 implementation that Elijah proposed operates through the array one at a time in O(n) producing a list of possible maximal sums which is extracted with >./ also in O(n). That kadane algorithm uses your technique in Chapter 25 Loopless Code VI, to perform a single run through the array. Just trying to be accurate so I can explain the implementations correctly in my essay. Pepe knew that >./ is very fast, probably 10% of the time of the other bit. The time spent in (([ >. +)/\.) is O(n), not worth our discussion; but if you want to blame someone for the speed, blame the implementation (i. e. me), not the algorithm. Perhaps (+ 00&>.)~/\. would be faster; I haven't tested it, but we're down to minute questions of instruction ordering. No complaints about J’s speed. Even the naive brute force implementation runs in less than a second on a 1 element array. I have been using the timings as a relative guage that the various implementations work the way I think they are supposed to. The one thing I did have a question on now that I’ve drawn you into this thread. Is that the memory requirement for Pepe’s algorithm is about 1/5 the size of the kadane”0 algorithm. The global variable assignment appears to be the operation that causes the large amount of memory to be used. Elijah tried to explain it and hsi explanation is valid for some of the implementations such as the use of ‘\’ and Fold. But I don’t understand in the setting of a global variable. Tom McGuire Henry Rich On 4/6/2023 8:12 PM, Thomas McGuire wrote: On Apr 3, 2023, at 1:28 PM, Jose Mario Quintana wrote: For what it is worth... kad=. >./@:(([ >. +)/\.) OK that is worth a lot. But it’s not really the kadane algorithm. It inserts a kadane-like summation in between elements for each suffix generated. Kadane obtains the sum on a single pass through the array. However it’s an incredibly elegant refactoring of the brute force example and saves performing partial sums on the suffixes. I will say after figuring out exactly what is was doing it wasn’t intuitively obvious (to me anyway) that this
Re: [Jprogramming] kadane algorithm vs brute force timing and memory
I think that when you say Pepe's code is not the Kadane algorithm you are conflating algorithm and implementation. Kadane's idea is that (1) at each new prospective starting point for the maximal sequence, you have the option of starting at 0 or the previous best total; (2) every position is a prospective ending point. Pepe's algorithm follows these observations. The usual implementations keep two values through the loop: (a) the maximum value found on sequences that have ended; (b) the current total on sequences that the new value may add onto. Well, that's one way to do it. Another is to produce (a) as an intermediate result for each possible ending position, and then at the end see which of those values is the largest. That's what Pepe did. I approve his decision, since keeping two values through the scan would require ponderous indexing operations. This is the sort of implementation decision that surprises users of compiled languages. Pepe's implementation in no way changes the algorithm. It's merely a reordering of when comparisons are made. Pepe's algorithm is O(n), just as the usual algorithms are. Pepe knew that >./ is very fast, probably 10% of the time of the other bit. The time spent in (([ >. +)/\.) is O(n), not worth our discussion; but if you want to blame someone for the speed, blame the implementation (i. e. me), not the algorithm. Perhaps (+ 00&>.)~/\. would be faster; I haven't tested it, but we're down to minute questions of instruction ordering. Henry Rich On 4/6/2023 8:12 PM, Thomas McGuire wrote: On Apr 3, 2023, at 1:28 PM, Jose Mario Quintana wrote: For what it is worth... kad=. >./@:(([ >. +)/\.) OK that is worth a lot. But it’s not really the kadane algorithm. It inserts a kadane-like summation in between elements for each suffix generated. Kadane obtains the sum on a single pass through the array. However it’s an incredibly elegant refactoring of the brute force example and saves performing partial sums on the suffixes. I will say after figuring out exactly what is was doing it wasn’t intuitively obvious (to me anyway) that this should work. A naive view is that the largest sum in the example below is produced by the subsequence : 4 _1 2 1 So that sequence is never generated in Jose’s version of maximum sum. However due to it’s Kadane-like properties it is generating the highest sum for each suffix as if the partial sum started at the first element. In essence using a kadane-like approach in place of performing partial sums. Therefore in one pass on each suffix you find the greatest partial sum without having to calculate each partial sum individually. Jose’s version is fairly quick coming in at about double the processing time of Jose’s kadane”0 version and well below the brute force method of taking the partial sums of all the suffixes. Tom McGuire For example, the maximum sum subarray, kad _2 1 _3 4 _1 2 1 _5 4 6 kad i.0 __ On Mon, Apr 3, 2023 at 5:22 AM Elijah Stone wrote: Your kadane routines are all bound to have asymptotically poor space usage under the present interpreter because >./ is not fused; so they all must create an intermediate result array whose length is the same as ranvec, and then apply >./. I think (haven't looked very closely) that locmax is the same as your final answer; so you could skip generating the intermediate array and simply look at locmax. Better yet, get rid of the global variable, and turn this all into a fold single (rather than fold multiple), where locmax becomes the running value. On Mon, 3 Apr 2023, Elijah Stone wrote: 7!:2 '>./ 1 kadane\ ranvec' [ locmax=: __ 1412576 7!:2 '>./ kadane"0 ranvec' [ locmax=: __ 772960 7!:2 '>./ kadane"1 ranvec2' [ locmax=: __ [ ranvec2=: ,.ranvec 1412960 1 <@$@$\ i.5 ┌─┬─┬─┬─┬─┐ │1│1│1│1│1│ └─┴─┴─┴─┴─┘ <@$@$"0 i.5 ┌─┬─┬─┬─┬─┐ │0│0│0│0│0│ └─┴─┴─┴─┴─┘ 1 kadane\ y applies kadane to length-1 subsequences of y--that is, in this case, vectors, which have length 1. Whereas kadane"0 applies to cells of y, which have rank 0. More space is required to store a length-1 vector than a scalar, since in the former case the length also needs to be stored. On Mon, 3 Apr 2023, Thomas McGuire wrote: I’m wondering if someone with more J internals knowledge can tell me why my Kadane algorithm implementation is taking up more memory than my naive brute force method that generates all subsequences then sums them. The time is about what I would expect except for the FOLD operation. The time space data were generated on a MacBook Pro 2019 era I9 processor 2.3GHz. ranvec =: _5 + ?1$10 kadane =: 3 : 'locmax =: y >. locmax + y' kadane1 =: 3 : 'locmax =: (] >. locmax&+) y' NB. first brute force implementation timespacex '>./(>./@(+/\))\.ranvec' 0.032948 396448 NB. fork version brute force timespacex '>./([: &
Re: [Jprogramming] Modular arithmetic support
Domain error. Henry Rich On Tue, Apr 4, 2023, 6:56 PM 'Mike Day' via Programming < programm...@jsoftware.com> wrote: > Lovely. Hopefully including negative powers! How will you deal with > ill-defined results, > though? > > Thanks, > > Mike > > Sent from my iPad > > > On 4 Apr 2023, at 19:07, Henry Rich wrote: > > > > Expect primitive support for modular inverse in an upcoming beta. > > > > Henry Rich > > > > > >> On Tue, Apr 4, 2023, 1:49 PM 'Michael Day' via Programming < > >> programm...@jsoftware.com> wrote: > >> > >> Thanks, Chris, and Cliff too. > >> > >> Yes, a mod inverse helps a lot. Once you've got an inverse, it's easy > >> to derive a modular divide, or vice > >> versa. > >> > >> inversep in primutil.ijs is well defined for a prime modulus - the name > >> "primutil" does of course imply > >> a prime modulus. > >> inversep also appears to work ok for those numbers in the ring of > >> integers modulo non-prime modulus. > >> > >> eg members of the ring modulo 10 are {1 3 7 9} > >>{{ y,:y (10 mtimes) (10)"0 y}} 1 3 7 9 > >> 1 3 7 9 > >> 1 1 1 1 > >>{{ y,:y (10 mtimes) (10)"0 y}} 1 3 7 9 > >> 1 3 7 9 > >> 1 1 1 1 > >> > >> I find rather better performance with my mrecip: > >> ts =: 6!:2 , 7!:2@] > >> > >>1 p: 19 > >> 1 > >> > >>ts'10009 mrecip 99000 + >:i.1007' > >> 0.0061255 22592 > >>ts'10009 inversep"0] 99000 + >:i.1007' > >> 0.0798054 97160 > >>ts'10009 mi"0] 99000 + >:i.1007' > >> 0.0908823 174192 > >> > >> A bit surprising as the Extended Euler Algorithm is supposed to be best > >> for getting a modular inverse. > >> > >> 19 (mrecip-:inversep"0) 99000 + >:i.1007 > >> 1 > >>19 ((19 mi)"0 @] -:inversep"0) 99000 + >:i.1007 > >> 1 > >> > >> Here's mrecip: > >> > >> mrecip =: {{ > >> y (x&|@^) <: 5 p: x > >> }}"0 > >> > >> As for inversep, and Cliff's mi, mrecip is well-defined for prime x, > >> and also for composite > >> x for y in x's ring, ie where 1 = x +. y > >> > >> Results are NOT reliable for arguments not coprime with the modulus. > >> > >> Thanks, > >> > >> Mike > >> > >>> On 03/04/2023 16:22, chris burke wrote: > >>> Cliff > >>> > >>> There are some mod functions in the math/misc addon, e.g. this gives > >>> Mike Day's table > >>> > >>>load 'math/misc/primutil' > >>>f=: (17 timesmod) (17) > >>>2 3 4 f"0 table >:i.8 > >>> +---+-+ > >>> |f"0|1 2 3 4 5 6 7 8| > >>> +---+-+ > >>> |2 |2 1 12 9 14 6 10 13| > >>> |3 |3 10 1 5 4 9 15 11| > >>> |4 |4 2 7 1 11 12 3 9| > >>> +---+-+ > >>> > >>> Any improvements welcome, thanks. > >>> > >>> Chris > >>> > >>> On Mon, Apr 3, 2023 at 5:49 AM Clifford Reiter > >> wrote: > >>>> I dug up an old extended gcd to build an adverb for modular divide > >>>> > >>>> NB. Find the gcd of two numbers > >>>> > >>>> NB. and coef giving gcd as a linear combination of y > >>>> > >>>> gcd2x=: 3 : 0 > >>>> > >>>> 'r0 r1'=.y > >>>> > >>>> 's0 s1'=.1 0x > >>>> > >>>> 't0 t1'=.0 1x > >>>> > >>>> while. r1 ~: 0 do. > >>>> > >>>> q=. r0 <.@% r1 > >>>> > >>>> 'r0 r1'=. r1,r0-q*r1 > >>>> > >>>> 's0 s1'=. s1,s0-q*s1 > >>>> > >>>> 't0 t1'=. t1,t0-q*t1 > >>>> > >>>> end. > >>>> > >>>> r0,s0,t0 > >>>> > >>>> ) > >>>> > >>>> gcd2x 51 119 > >>>> > >>>> 17 _2 1 > >>>> > >>>> _2 1 +/ . * 51 119 > >>>> > >>>> 17 > >>>> > >>>> NB. adverb giving
Re: [Jprogramming] Modular arithmetic support
Expect primitive support for modular inverse in an upcoming beta. Henry Rich On Tue, Apr 4, 2023, 1:49 PM 'Michael Day' via Programming < programm...@jsoftware.com> wrote: > Thanks, Chris, and Cliff too. > > Yes, a mod inverse helps a lot. Once you've got an inverse, it's easy > to derive a modular divide, or vice > versa. > > inversep in primutil.ijs is well defined for a prime modulus - the name > "primutil" does of course imply > a prime modulus. > inversep also appears to work ok for those numbers in the ring of > integers modulo non-prime modulus. > > eg members of the ring modulo 10 are {1 3 7 9} > {{ y,:y (10 mtimes) (10)"0 y}} 1 3 7 9 > 1 3 7 9 > 1 1 1 1 > {{ y,:y (10 mtimes) (10)"0 y}} 1 3 7 9 > 1 3 7 9 > 1 1 1 1 > > I find rather better performance with my mrecip: > ts =: 6!:2 , 7!:2@] > > 1 p: 19 > 1 > > ts'10009 mrecip 99000 + >:i.1007' > 0.0061255 22592 > ts'10009 inversep"0] 99000 + >:i.1007' > 0.0798054 97160 > ts'10009 mi"0] 99000 + >:i.1007' > 0.0908823 174192 > > A bit surprising as the Extended Euler Algorithm is supposed to be best > for getting a modular inverse. > >19 (mrecip-:inversep"0) 99000 + >:i.1007 > 1 > 19 ((19 mi)"0 @] -:inversep"0) 99000 + >:i.1007 > 1 > > Here's mrecip: > > mrecip =: {{ > y (x&|@^) <: 5 p: x > }}"0 > > As for inversep, and Cliff's mi, mrecip is well-defined for prime x, > and also for composite > x for y in x's ring, ie where 1 = x +. y > > Results are NOT reliable for arguments not coprime with the modulus. > > Thanks, > > Mike > > On 03/04/2023 16:22, chris burke wrote: > > Cliff > > > > There are some mod functions in the math/misc addon, e.g. this gives > > Mike Day's table > > > > load 'math/misc/primutil' > > f=: (17 timesmod) (17) > > 2 3 4 f"0 table >:i.8 > > +---+-+ > > |f"0|1 2 3 4 5 6 7 8| > > +---+-+ > > |2 |2 1 12 9 14 6 10 13| > > |3 |3 10 1 5 4 9 15 11| > > |4 |4 2 7 1 11 12 3 9| > > +---+-+ > > > > Any improvements welcome, thanks. > > > > Chris > > > > On Mon, Apr 3, 2023 at 5:49 AM Clifford Reiter > wrote: > >> I dug up an old extended gcd to build an adverb for modular divide > >> > >> NB. Find the gcd of two numbers > >> > >> NB. and coef giving gcd as a linear combination of y > >> > >> gcd2x=: 3 : 0 > >> > >> 'r0 r1'=.y > >> > >> 's0 s1'=.1 0x > >> > >> 't0 t1'=.0 1x > >> > >> while. r1 ~: 0 do. > >> > >> q=. r0 <.@% r1 > >> > >> 'r0 r1'=. r1,r0-q*r1 > >> > >> 's0 s1'=. s1,s0-q*s1 > >> > >> 't0 t1'=. t1,t0-q*t1 > >> > >> end. > >> > >> r0,s0,t0 > >> > >> ) > >> > >> gcd2x 51 119 > >> > >> 17 _2 1 > >> > >> _2 1 +/ . * 51 119 > >> > >> 17 > >> > >> NB. adverb giving divide (inverse) mod m > >> > >> mi=:1 : 0"0 > >> > >> 'r0 s0 t0'=:gcd2x m,y > >> > >> if. r0=1 do. m|t0 else. 1r0 end. > >> > >> : > >> > >> m|x*m mi y > >> > >> ) > >> > >> 17 mi 6 > >> > >> 3 > >> > >> NB. Mike Day's Table > >> > >> 2 3 4 (17 mi)table >:i.8 > >> > >> +-+-+ > >> > >> | |1 2 3 4 5 6 7 8| > >> > >> +-+-+ > >> > >> |2|2 1 12 9 14 6 10 13| > >> > >> |3|3 10 1 5 4 9 15 11| > >> > >> |4|4 2 7 1 11 12 3 9| > >> > >> +-+-+ > >> > >> > >> I have some questions regarding system solving modulo m that I will > offer > >> in a new thread in a few days. > >> > >> Best, Cliff > >> > >> On Thu, Mar 30, 2023 at 12:11 PM Clifford Reiter > >> wrote: > >> > >>> I think I recall a conversation, some decades ago, with Roger about > >>> whether specifying a modulus for system solving makes sense for J. I > >>> thought maybe that was a use for the fit conjunction but now think that > >>> would be a poor choice for such a numeric function.
Re: [Jprogramming] distance makes the heart grow fonder
When is linebreak used? That is, when is it superior to [? Henry Rich On 4/1/2023 11:29 AM, Eric Iverson wrote: I am in favor of linebreak as well as a linejoin. I'd very much like to have an easier to type NB. .. NB. ... linejoin (followed by comment) linebreak I used to think internal and nested comments were important, but not anymore. Not enough bang for the required mechanism. On Sat, Apr 1, 2023 at 10:48 AM Jan-Pieter Jacobs < janpieter.jac...@gmail.com> wrote: I'd be in favour of both .. and ... . Regarding ... , I'd like to note that Matlab uses the same as line joiner (see https://www.mathworks.com/help/matlab/matlab_prog/continue-long-statements-on-multiple-lines.html ), and also turns everything after that into a comment (which is very handy). This would let one also comment longer tacit verbs well, without any extraneous NB.'s . Trivial example would be: avg =: ... +/ ... sum % ... divided by # ... count Your first comment would be incompatible with the easy commenting (without using NB.). I don't like the .:. proposal, since it is more difficult to type different characters instead of the same; I'd rather have ::: (could imagine them looking like the holes for shoelaces, that can be used to tie together lines)... Jan-Pieter On Sat, 1 Apr 2023, 11:26 Elijah Stone, wrote: Some time ago, Michal proposed that a line separator be added. I want to rekindle that discussion. The proposal was that .. behave like a line break when placed on a single line, such that e.g. {{ a=. y+y .. a }} 2 would do the obvious thing. Short, distinctive, and to the point. I also want to propose a line _joiner_, analogous to \ in shell or c: ..., placed at the beginning or end of a line should join it with the previous or next. Joining lines happens _after_ stripping comments, unlike the other languages I cited; the goal is to enable large, multi-line definitions with commentary for intermediate terms, without the need for pointless intermediate definitions. It might be objectionable to use such similar symbols for separators and joiners. But maybe it's not such a big deal. Two more ideas: 1. Could use the _same_ symbol for both, with its sense depending on where it's placed in a line. 2. Separator could be .:.; metaphor: a hill stops the interpreter in its tracks. I don't like 2 because the larger the separator is, the more annoying it is to use. Joiner can afford to be large, since it only comes into play if the rest of the line is sufficiently large. Anyway--thoughts? Comments? Suggestions? -E -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Strange error
I see. I couldn't get the same failure because I was using jconsole, and your characters didn't make it through email. The spelling error is from executing a boxing character. You are executing in each box to produce a list of boxes; then formatting that to a 3xn array of characters; then executing each row of the array. The characters are Unicode and give spelling error. Use ;@:("."0@":&.>) 40 5 9008 90 Henry Rich On 3/30/2023 2:52 PM, Richard Donovan wrote: Hi Henry I deleted all the spaces and replaced with “real” ones. Still in error Ran a.i. Which seems ok… a.i.'".@": "."0@": each 405 90' 34 46 64 34 58 32 34 46 34 48 64 34 58 32 101 97 99 104 32 52 48 53 32 57 48 ".@": "."0@": each 405 90 |spelling error | | ^ | ".@":"."0@":each 405 90 I would love to migrate to 9.4 but Windows Defender resolutely refuses to run the installation file and does not even allow me to override and continue. I’ve been installing new releases since J402 and this is the first problem I’ve had! Richard On 30 Mar 2023, at 18:06, Henry Rich wrote: My guess is you pasted in a nonbreaking space. The caret points to the error. Wouldn't you like release 9.4, which would give more error information? Henry Rich On 3/30/2023 12:54 PM, Richard Donovan wrote: JVERSION Engine: j902/j64avx2/windows Release-a: commercial/2020-12-05T13:36:01 Library: 9.02.08 Qt IDE: 1.9.2s/5.12.10(5.12.10) Platform: Win 64 Installer: J902 install InstallPath: c:/program files/j902 ".@": "."0@": each 40 5 9008 90 |spelling error | | ^ | ".@":"."0@":each 40 5 9008 90 (NB. required output 4 0 5 9 0 0 8 9 0) The boxed question marks actually appear as an assortment of left, up, and down arrows. This is reproducible. I need a list of all the digits in y, concatenated as shown, with zeros retained Thanks for any help Richard -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Strange error
My guess is you pasted in a nonbreaking space. The caret points to the error. Wouldn't you like release 9.4, which would give more error information? Henry Rich On 3/30/2023 12:54 PM, Richard Donovan wrote: JVERSION Engine: j902/j64avx2/windows Release-a: commercial/2020-12-05T13:36:01 Library: 9.02.08 Qt IDE: 1.9.2s/5.12.10(5.12.10) Platform: Win 64 Installer: J902 install InstallPath: c:/program files/j902 ".@": "."0@": each 40 5 9008 90 |spelling error | | ^ | ".@":"."0@":each 40 5 9008 90 (NB. required output 4 0 5 9 0 0 8 9 0) The boxed question marks actually appear as an assortment of left, up, and down arrows. This is reproducible. I need a list of all the digits in y, concatenated as shown, with zeros retained Thanks for any help Richard -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] whence 'foo upon thee'?
I think it's Roger's variation on "fie upon thee". Henry Rich On Sat, Mar 18, 2023, 7:46 AM Elijah Stone wrote: > The phrase 'foo upon thee' appears many times in the j test suite. > > A google search reveals a forum post by roger from 1994 > (http://computer-programming-forum.com/9-apl/a0e17b293b053c07.htm) and an > article by robert bernecky from 1975 > (http://www.snakeisland.com/IPSANewsletter_1974_75_12_01.pdf). Does > anyone > know where it originates? > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Glo.bal Symbols Table 0 s: 10
Rather than describe it, I have written you verbs to convert symbols into a list of boxed strings and vice versa. It is up to you to apply the verbs, save results, etc.: NB. Returns currently-defined symbols, as (list of characters);(list of symbol lengths) getsyms =: {{ indexes =. 0 0 -.~ 2 {."1(0) s: 2 NB. (index,length) of each symbol symchars =. (,"0 indexes) ;@:(<;.0) 0 s: 3 NB. fetch each symbol and run them together symchars ; {:"1 indexes }} NB. Applies to result of getsyms, to create boxed strings. Apply s: to result if desired setsyms =: {{ 'chars lens' =. y ((,:~"0 [: |.!.0 +/\) lens) <;.0 chars NB. create start,:length of each string and box them }} The documentation of /what/ s: does is at https://www.jsoftware.com/help/dictionary/dsco.htm . /How/ it does it is to be learned from the source code, and you are own your own there. There are a few comments. Henry Rich On 3/14/2023 1:04 AM, Ak O wrote: lol a few, and I expect many more. What command restores each in their correct position Store is? (3!:1) (0 s: 3) 1!:2<...' (3!:1) (2 {."1(0) s: 2) 1!:2 <...' Restore? ???(3!:2) 1!:1<...' ???(3!:2) 1!:1<...' Also, I wonder if there is a resource I can consult to understand better how the Symbols Interpreter works? Thanks again Ak. On Mon., Mar. 13, 2023, 20:15 Henry Rich, wrote: You must have a lot of symbols. A symbol represents a list of characters. If you are trying to save/restore the symbols, 0 s: 10 is giving much more information th you need. All you need is the list of strings run end-to-end (0 s: 3) and the index/lenpgth of each (2 {."1 (0) s: 2) . Henry Rich.m On 3/13/2023 9:02 PM, Ak O wrote: I hope you are all well. Is there a mechanism for storing the Global Symbols Data in parts? Also restoring from those parts? The documented methods of: ((3!:1) 0 s: 10) 1!:2<'symb_tbl_dat.dat' 10 s: (3!:2)1!:1<'symb_tbl_dat.dat' had been working well but now seems to have hit a limit. When I try to store the GST, I now trigger the out of memory error. I thought about storing the columns individually. ((3!:1)0{(0 s: 10)) 1!:2<'symb_tbl_col_0.dat' ...7{(0 s: 10)... I cannot seem to 'install' the columns to restore the whole table. Is there some way chunking the Global Symbols Data into pieces? Or pack it more tightly? Or some other thing I might not have considered? Thanks Ak -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Global Symbols Table 0 s: 10
You must have a lot of symbols. A symbol represents a list of characters. If you are trying to save/restore the symbols, 0 s: 10 is giving much more information than you need. All you need is the list of strings run end-to-end (0 s: 3) and the index/length of each (2 {."1 (0) s: 2) . Henry Rich On 3/13/2023 9:02 PM, Ak O wrote: I hope you are all well. Is there a mechanism for storing the Global Symbols Data in parts? Also restoring from those parts? The documented methods of: ((3!:1) 0 s: 10) 1!:2<'symb_tbl_dat.dat' 10 s: (3!:2)1!:1<'symb_tbl_dat.dat' had been working well but now seems to have hit a limit. When I try to store the GST, I now trigger the out of memory error. I thought about storing the columns individually. ((3!:1)0{(0 s: 10)) 1!:2<'symb_tbl_col_0.dat' ...7{(0 s: 10)... I cannot seem to 'install' the columns to restore the whole table. Is there some way chunking the Global Symbols Data into pieces? Or pack it more tightly? Or some other thing I might not have considered? Thanks Ak -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] plot and paint demo
Please, help us by updating the wiki. At this moment you know more about this misdescription than anyone else. Henry Rich On 3/12/2023 10:01 PM, More Rice wrote: I still couldn't find the equivalent of xticklabels Ok. Figured it out. The description of xlabel in jwiki is wrong - It is not "datapoint" (based on the error message, it should be "one label per tic position"). xlabel* c [#none ] x labels (one label per datapoint) It works wonderfully. Thank you very much for the package! thank you. Maurice On Sun, Mar 12, 2023 at 5:53 PM More Rice wrote: Thank you, Rob. I (could easily find and) read those links before my initial ques email. I'll give you the longer story. I had issue reconciling what I read from 2 sources: A. From calculus.pdf, page 7 - more than 1 plot types are given to the plot verb as its x argument: load 'plot' PLOT=:’stick,line’ PLOT t;h B. From the Plot/Verbs page (https://code.jsoftware.com/wiki/Plot/Verbs), it said they should be separated by semicolons. Then, where does the comma come from? So, I thought the documentation was no longer up-to-date. And the following experiments caused me further confusion: 'stick,line ; yrange _2 2 ; xtic 1p1 3' plot _2p1 2p1 ; 'sin' NB. works 'yrange _2 2 ; xtic 1p1 3 ; stick,line' plot _2p1 2p1 ; 'sin' NB. doesn't |option not found: stick,line: signal | signal'option not found: ',j I read some more this morning, and did more experiments. It seems 'stick,line' belongs to the type option, and by default (only in the beginning of x), plot assumes type's value string (and the comma is actually optional). If we need to put them aside from the beginning of x, we seem to have to explicitly use the type option keyword. 'yrange _2 2 ; xtic 1p1 3 ; type stick,line' plot _2p1 2p1 ; 'sin' NB. works This for pointing me back to the jwiki for a second look to figure this out. That said, I still couldn't find the equivalent of xticklabels ( https://www.mathworks.com/help/matlab/ref/xticklabels.html) in J yet. Not yet implemented? thank you. Maurice On Sun, Mar 12, 2023 at 3:02 AM 'robert therriault' via Programming < programm...@jsoftware.com> wrote: Hi Maurice, With respect to finding the documentation on the wiki, have you looked at https://code.jsoftware.com/wiki/Plot and in particular https://code.jsoftware.com/wiki/Plot/Options A lot of the fine tuning of Plot seems to be done through pd. The Development section of the plot page may also give you some useful information. My apologies if you have already looked at them and found them wanting, but when you said you did not find the doc in the wiki, I just wanted to be sure that you were aware of these. Cheers, bob On Mar 11, 2023, at 22:07, More Rice wrote: Hi, some questions, if I may ... 1. plot can't handle asymptote (or "not in domain" issue) right at the boundary in its domain? install 'all' load 'plot trig numeric' plot _5 5 ; '%' NB. ok plot _5 0 ; '%' NB. Bad |NaN error: plotfintvl | bakproj=.({:"1 zvals),~"0 1(}."1 zvals) -(}."1 secant)*"1 intsize plot 0 5 ; '%' NB. Bad |NaN error: plotfintvl | fwdproj=.({."1 zvals),"0 1(}:"1 zvals) +(}:"1 secant)*"1 intsize plot 0 10; '%:' NB. ok plot _1 10; '%:' NB. Bad |domain error: plotsubd | mtone1=. (<./@:i.&0)@:(2&(<:/\)))>.((i.&0)@:(2&(>:/\"1))@(1&{::)"1 d JVERSION Engine: j903/j64avx2/windows Release-b: commercial/2022-01-28T04:09:50 Library: 9.03.08 Qt IDE: 1.9.5s/5.15.2(5.15.2) Platform: Win 64 Installer: J903 install InstallPath: c:/users/myself/software/j903 Contact: www.jsoftware.com 2. I'm trying to control plot's y-scale and x-/y-tick labels. I don't see its doc in jwiki nor calculus.pdf. So, I tried scrolling through Help|Studio|Showcase...|plot to see if they're possible; but still nothing. For example, instead of a numeric value, I want to do 0, +/- 1p1, +/- 2p1, etc. Can it be done? 3. While looking for solution to #2, I stumbled upon a bug: Help|Studio|Showcase...|isigraph. Repeatedly pressing F12 till you see 'Screen Roller' (yes, ignore Paint Demo and just hit another F12). Once you reach this stage, Paint Demo will relaunch if you try to exit the window. In the end, I've to kill the jqt to get out of the demo. thanks Maurice -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] plot and paint demo
I reckon if the function can't be evaluated at the endpoint, plot should narrow the interval until it can be. I don't see myself having time to work on this any time soon, so if someone else wants to step up and make this change, please do. [Chris did 99.9% of the work on Plot but this bug is mine.] Henry Rich On 3/12/2023 1:07 AM, More Rice wrote: Hi, some questions, if I may ... 1. plot can't handle asymptote (or "not in domain" issue) right at the boundary in its domain? install 'all' load 'plot trig numeric' plot _5 5 ; '%' NB. ok plot _5 0 ; '%' NB. Bad |NaN error: plotfintvl | bakproj=.({:"1 zvals),~"0 1(}."1 zvals) -(}."1 secant)*"1 intsize plot 0 5 ; '%' NB. Bad |NaN error: plotfintvl | fwdproj=.({."1 zvals),"0 1(}:"1 zvals) +(}:"1 secant)*"1 intsize plot 0 10; '%:' NB. ok plot _1 10; '%:' NB. Bad |domain error: plotsubd | mtone1=. (<./@:i.&0)@:(2&(<:/\)))>.((i.&0)@:(2&(>:/\"1))@(1&{::)"1 d JVERSION Engine: j903/j64avx2/windows Release-b: commercial/2022-01-28T04:09:50 Library: 9.03.08 Qt IDE: 1.9.5s/5.15.2(5.15.2) Platform: Win 64 Installer: J903 install InstallPath: c:/users/myself/software/j903 Contact: www.jsoftware.com 2. I'm trying to control plot's y-scale and x-/y-tick labels. I don't see its doc in jwiki nor calculus.pdf. So, I tried scrolling through Help|Studio|Showcase...|plot to see if they're possible; but still nothing. For example, instead of a numeric value, I want to do 0, +/- 1p1, +/- 2p1, etc. Can it be done? 3. While looking for solution to #2, I stumbled upon a bug: Help|Studio|Showcase...|isigraph. Repeatedly pressing F12 till you see 'Screen Roller' (yes, ignore Paint Demo and just hit another F12). Once you reach this stage, Paint Demo will relaunch if you try to exit the window. In the end, I've to kill the jqt to get out of the demo. thanks Maurice -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] J shell scripts
What we have agreed to do is to treat a #! line as a comment ONLY when #! are the first 2 characters of a file loaded by 0!:n (which is used by the load command). Henry Rich On 3/10/2023 7:29 PM, Raul Miller wrote: Byte order mark is another can of worms, as is wide encoding. But, yes, currently, shebang handling on the J side relies on undefined verb parsing. If we handle shebang lines, a question becomes: how much handling should be done? (For example, does #! become a comment prefix? In many interpreted languages, # marks the beginning of a comment which ends at line end.) (Also, if the J interpreter cannot find itself at the shebang path (delimited by a terminating space), should it pass control to that interpreter? This is how perl handles shebang lines...) Etc. -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] J shell scripts
"Ancillary Pages" is on the main NuVoc page; there is also a pointer to the details for !:, with a banner, in the NuVoc page for !: . Why don't you add a reference to it in the places you looked? Henry Rich On 3/10/2023 6:42 PM, Don Guinn wrote: I used the link to the "Earlier Reference Sources". Found the link you sent me buried in "Ancillary Pages". Something so useful should be easier to find. On Fri, Mar 10, 2023 at 9:23 AM Henry Rich wrote: Yes it is: https://code.jsoftware.com/wiki/Vocabulary/Foreigns#m9 Henry Rich On 3/10/2023 11:06 AM, Don Guinn wrote: What is 9!:55 ? Not shown in the !: conjunction. On Fri, Mar 10, 2023 at 8:46 AM Henry Rich wrote: If we do that, should we revisit the question of ignoring the BOM (Byte Order Mark) that editors sometimes put at the beginning of scripts? Does the shebang take advantage of the fact that the first line is parsed into a bunch of undefined names taken to be a verb? Does that mean that if username is 'monad', or any noun defined in the user's profile, that the script will fail? If so, I think that should be changed. I would like to encourage users to use 9!:55 to find garbage lines and they can't very well do that if we depend on them. Is there a good reason not to ignore the shebang line explicitly, rather than putting our faith in garbage processing? Henry Rich On 3/10/2023 12:04 AM, Elijah Stone wrote: Perhaps it's simply time to tell the interpreter to start ignoring the first line of a script if it starts with #!... On Thu, 9 Mar 2023, Raul Miller wrote: The recent change in directory naming from j903 to j9.4 introduces an interesting issue for shell scripts on unix-like systems. In J shell scripts, this works: #!/home/username/j903/bin/jconsole However, this fails with a spelling error: #!/home/username/j9.4/bin/jconsole Or, on OSX, the shebang line is different, but the spelling error remains: #!/Applications/j9.4/bin/jconsole That said, there's some other issues here, related to portability. One of which is that (as a general rule) a home directory is personal rather than portable. Another is that there's official java jconsole which does not understand J. But, also, for a long time now, Debian based distributions have been distributing j with /usr/bin/ijconsole as a symbolic link to the current installed location for J. (Here, the 'i' in ijconsole stands for Iverson.) So I think that now would be a good time to adopt that as "documented standard practice" for j shell scripts. FYI, -- Raul -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] J shell scripts
Yes it is: https://code.jsoftware.com/wiki/Vocabulary/Foreigns#m9 Henry Rich On 3/10/2023 11:06 AM, Don Guinn wrote: What is 9!:55 ? Not shown in the !: conjunction. On Fri, Mar 10, 2023 at 8:46 AM Henry Rich wrote: If we do that, should we revisit the question of ignoring the BOM (Byte Order Mark) that editors sometimes put at the beginning of scripts? Does the shebang take advantage of the fact that the first line is parsed into a bunch of undefined names taken to be a verb? Does that mean that if username is 'monad', or any noun defined in the user's profile, that the script will fail? If so, I think that should be changed. I would like to encourage users to use 9!:55 to find garbage lines and they can't very well do that if we depend on them. Is there a good reason not to ignore the shebang line explicitly, rather than putting our faith in garbage processing? Henry Rich On 3/10/2023 12:04 AM, Elijah Stone wrote: Perhaps it's simply time to tell the interpreter to start ignoring the first line of a script if it starts with #!... On Thu, 9 Mar 2023, Raul Miller wrote: The recent change in directory naming from j903 to j9.4 introduces an interesting issue for shell scripts on unix-like systems. In J shell scripts, this works: #!/home/username/j903/bin/jconsole However, this fails with a spelling error: #!/home/username/j9.4/bin/jconsole Or, on OSX, the shebang line is different, but the spelling error remains: #!/Applications/j9.4/bin/jconsole That said, there's some other issues here, related to portability. One of which is that (as a general rule) a home directory is personal rather than portable. Another is that there's official java jconsole which does not understand J. But, also, for a long time now, Debian based distributions have been distributing j with /usr/bin/ijconsole as a symbolic link to the current installed location for J. (Here, the 'i' in ijconsole stands for Iverson.) So I think that now would be a good time to adopt that as "documented standard practice" for j shell scripts. FYI, -- Raul -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] J shell scripts
If we do that, should we revisit the question of ignoring the BOM (Byte Order Mark) that editors sometimes put at the beginning of scripts? Does the shebang take advantage of the fact that the first line is parsed into a bunch of undefined names taken to be a verb? Does that mean that if username is 'monad', or any noun defined in the user's profile, that the script will fail? If so, I think that should be changed. I would like to encourage users to use 9!:55 to find garbage lines and they can't very well do that if we depend on them. Is there a good reason not to ignore the shebang line explicitly, rather than putting our faith in garbage processing? Henry Rich On 3/10/2023 12:04 AM, Elijah Stone wrote: Perhaps it's simply time to tell the interpreter to start ignoring the first line of a script if it starts with #!... On Thu, 9 Mar 2023, Raul Miller wrote: The recent change in directory naming from j903 to j9.4 introduces an interesting issue for shell scripts on unix-like systems. In J shell scripts, this works: #!/home/username/j903/bin/jconsole However, this fails with a spelling error: #!/home/username/j9.4/bin/jconsole Or, on OSX, the shebang line is different, but the spelling error remains: #!/Applications/j9.4/bin/jconsole That said, there's some other issues here, related to portability. One of which is that (as a general rule) a home directory is personal rather than portable. Another is that there's official java jconsole which does not understand J. But, also, for a long time now, Debian based distributions have been distributing j with /usr/bin/ijconsole as a symbolic link to the current installed location for J. (Here, the 'i' in ijconsole stands for Iverson.) So I think that now would be a good time to adopt that as "documented standard practice" for j shell scripts. FYI, -- Raul -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Locale + gl2 + Timer Mystery
The mouseMove handler would have the form selected. Perhaps you need to select the form, and glselect the isigraph, inside your timer? paint_base_ '' is the preferable way to change locales. Henry Rich On 3/8/2023 2:45 PM, Ed Gottsman wrote: Hello. I’ve got a timer firing a callback routine (in the z locale, of course) that in turn needs to call a paint routine in the base locale. I’ve tried sys_timer_z_ =: 3 : 0 cocurrent <‘base' paint ‘' ) …as well as sys_timer_z_ =: 3 : 0 paint_base_ '' ) Both work, actually, in that they call paint…except: The paint routine makes a series of gl2 calls. All of them work, too. The only problem is that the first gl2 call (it doesn’t seem to matter what gl2 routine is being called) prints: |domain error: chkgl2 | glfill 255 255 255 255 …to the terminal. (In this case, the first call was to glfill.). This would not be a serious problem except that I’m doing animation and shooting for 30 fps. Flooding the terminal with spurious gl2 errors will make other debug output difficult to find. Note that I call the same paint routine from a mouseMove event handler (interim solution)—in which case no gl2 error message is printed. That’s why I wonder about locales and the timer. Am I missing something obvious? Thanks. Ed -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] jqt documentation
sys_timer used to be called in base locale. Now it is called in z, as you can see from the message. Please fix the wiki. Henry Rich On Mon, Feb 27, 2023, 3:34 PM David Lambert wrote: > > https://code.jsoftware.com/wiki/Guides/Window_Driver/Window_Driver_Overview#System_Events > > I'd repair the value error if I knew how. > > JVERSION > > Engine: j9.4.0-beta13/j64avx2/linux > > Build: commercial/2023-02-23T11:24:28/clang-11-0-0/SLEEF=1 > > Library: 9.4.16 > > Qt IDE: 2.0.3/5.12.8(5.15.6) > > Platform: Linux 64 > > Installer: unknown > > InstallPath: /usr/share/j/9.04 > > Contact: www.jsoftware.com > > sys_timer=: (6!:0) (1!:2) 2: > > wd 'timer 1000' > > |value error: sys_timer_z_ > > | (i.0 0)"_ sys_timer_z_$0 > > |value error: sys_timer_z_ > > | (i.0 0)"_ sys_timer_z_$0 > > |value error: sys_timer_z_ > > | (i.0 0)"_ sys_timer_z_$0 > -- > For information about J forums see http://www.jsoftware.com/forums.htm > -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Applying a cyclic gerund
Now that gerund"n applies gerund cyclically, the need for the oblique trick is reduced. Henry Rich On 2/25/2023 3:26 PM, neit...@gaertner.de wrote: I want to convert the second one into numerical data Can you simplify the above expression? Applying a gerund cyclically, as asked for in the subject: ] list =. ;: 'foo 1 bar 2.17 baz 3.14' +---+-+---++---++ |foo|1|bar|2.17|baz|3.14| +---+-+---++---++ , ]`(".each)/. list +---+-+---++---++ |foo|1|bar|2.17|baz|3.14| +---+-+---++---++ (,: datatype each) , ]`(".each)/. list +---+---+---++---++ |foo|1 |bar|2.17|baz|3.14| +---+---+---++---++ |literal|boolean|literal|floating|literal|floating| +---+---+---++---++ Obliquing over a vector is often overlooked. It picks up every item as a singleton "diagonal". The final "," is required to compensate for that. Martin Neitzel -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Math/calculus simplify trig pull request
I agree about lines 164-166 and have no opinion about the rank of constants. Henry Rich On 2/24/2023 10:57 AM, Jan-Pieter Jacobs wrote: I was looking at Raul's pull request for math/calculus here: https://github.com/jsoftware/math_calculus/pull/5 . This would simplify a lot of derivatives, especially ones involving sines and cosines, which cause higher order derivatives to explode in the current version. I've been granted push rights on the repo, but I'm not 100% sure I understand the code proposed, and I'm also not sure how to use Github's code review tools (in fact, not being a programming professional, I never did a code review at all). How is this supposed to work? Are the Github tools used in general for collaboration on jsoftware's addons? I'm doubting about the lines 164-166 ( https://github.com/rdm/math_calculus/blob/796ddac9de3863bf6746861624bb6aad8b70b9a2/calculus.ijs#L164), where it seems to me that in x atops y, when y happens to be -@verb, just discards x and -@, keeping only "verb". I think this should only happen if x is -, i.e. I think a check is missing. Secondly, for now, constants, zeros, ones and negative ones are considered only if they are rank 0 (see lines 173, 178-180, at https://github.com/rdm/math_calculus/blob/796ddac9de3863bf6746861624bb6aad8b70b9a2/calculus.ijs#L173). Would it hurt to also accept them at other ranks (e.g. 0: , 0"_), e.g. would it have unexpected effects on pderiv? deriv_jcalculus already accepts 0: and related primitives for deriv and intg (and could likely be extended to accept 0"_, 1"_, etc as well). Thanks for your observations. Jan-Pieter PS: if you're all too busy preparing the j9.4 release, no rush, it can wait. -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Applying a cyclic gerund
ci =. 'abc';'13.2' (datatype L:0) 0 1 (0&".@])^:[ L:0"0 ci ---++ literal|floating| ---+----+ Henry Rich On 2/21/2023 11:08 PM, Gilles Kirouac wrote: I have two character strings : datatype each 'abc';'13.2' ┌───┬───┐ │literal│literal│ └───┴───┘ I want to convert the second one into numerical data datatype each (<@:])`(<@:".)"1 >'abc';'13.2' ┌───┬┐ │literal│floating│ └───┴┘ Can you simplify the above expression? ~ Gilles -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Atop parsing
Rank. The rank of *: is 0. Thus ... @ *: has rank 0. The rank of fork is _ . *: @: fork (equivalent to [: *: fork) has rank _ , as does (*: @ fork) Henry Rich On 2/12/2023 4:46 PM, More Rice wrote: Masters, I understand that there is an excellent reference implementation of varp in addons/stats/base/univariate.ijs to learn from, but I'm trying to do exercises to solidify my understanding of using verb trains/hooks, and the difference when using Atop. I've 2 versions of varp. #1 below is typical of what some of you do (credit: Bob's "Maximum Consecutive 1's in J." Excellent video! Thank you. I wish there were more of these.) - using cap when we want to string monadic verbs sequentially. No problem there. NB. works - using hook/fork/cap myvarp1 =: # %~ [: +/ [: *: (-+/%#) NB. works - using hook/fork/Atop and no cap myvarp2 =: # %~ +/ @ (*: @ (-+/%#)) #2 above, for some reason, I need an extra pair of parentheses to the right of the 1st @ for it to work. I don't get why. For example, the following is broken. NB. It gives me a list instead :( myvarp_broken =: # %~ +/ @ *: @ (-+/%#) Why are they (the missing parentheses w.r.t. #2) needed? thank you Maurice -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] p. _78 _1 0 0 0 1
Good find & fix. (i>>3)&8 was an attempt to fix earlier similar problems, and it did fix the ones that were reported! The 8 was a blunder, I meant 7. You are right that i&7 suffices. Henry Rich On 2/4/2023 11:07 PM, Elijah Stone wrote: I think the j implementation does exactly the same thing as the julia and bqn implementations: if(!--kicktimer){kicktimer=CSZ1; x=zplus(x,ztymes(dx,zrj0(cyclefracs[(i>>3)&8]))); Actually, now that I look at it, that's wrong. I'm not sure what (i>>3)&8 was supposed to be, but if I replace it with i&7, the code works fine. On Sat, 4 Feb 2023, Henry Rich wrote: That might well be what I'm seeing. The J implementation tries Laguerre, and if it fails perturbs the polynomial by 1e_12 in the leading coefficient. Do you think it would be better if instead I retried with a random starting point? I haven't checked for what the region of convergence of the starting point is. hhr On 2/4/2023 9:55 PM, Marshall Lochbaum wrote: Tried out my own Laguerre implementation from here: https://github.com/mlochbaum/bqn-libs/blob/master/polynomial.bqn#L80-L113 I remember I used J as a reference for this, but I think I ended up following this one in Julia: https://github.com/giordano/PolynomialRoots.jl/blob/master/src/PolynomialRoots.jl#L255 With the starting point at 0 it converges, but only with a few random adjustments from this line: { 0=jump_i|i ? root +↩ dx × Jump i÷jump_i ;@} Here Jump i÷jump_i just ignores the argument and produces a random float, ?0 in J (Julia has a table to avoid computing one). Removing this, I see a small region of non-convergence around 0, radius between 0.1 and 0.2. I suppose this isn't what you get? Marshall On Sat, Feb 04, 2023 at 08:34:46PM -0500, Henry Rich wrote: Somehow I lost the original post. For some reason Laguerre's method doesn't converge for this polynomial. There seem to be large regions of non-convergence. Changes of up to 1e_5 in any of the constants still fail to converge. The point seems to oscillate in a wide range but doesn't head toward any solution. In the implementation the initial guess is always 0j0. I don't see why this would fail. If anyone on this list can help, or knows someone who can help, I'd appreciate suggestions. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] p. _78 _1 0 0 0 1
It doesn't look like roundoff to me. Nonexpert opinion. hhr On 2/4/2023 10:04 PM, Elijah Stone wrote: Is it possible the culprit is floating-point roundoff? If so, perhaps the routine could be made to detect that automatically. You can get a conservative estimation of floating-point roundoff by using interval arithmetic, directing the hardware to alternately round towards positive and negative infinity for each operation; when the estimated roundoff is larger than the refinement you made to your root estimate, the latter is likely junk, so you should fall back to some alternate strategy. (When changing the rounding mode is somewhat expensive, as on x86 before avx512, you can get a slightly looser--but still pretty good--estimate by multiplying by 1-2^-52 or 1+2^-52. Those 'round' towards and away from zero, so some extra fanagling is required; this can be amortised by partitioning all terms according to sign, which is probably a good idea anyway.) It could also be worth looking at other approaches. Like I said before, I think bisection using intervals is a likely approach. I also found this thesis https://www.math.stonybrook.edu/~scott/Papers/thesis-alt.pdf which talks about forcing newton to converge, which seems promising. On Sat, 4 Feb 2023, Henry Rich wrote: Somehow I lost the original post. For some reason Laguerre's method doesn't converge for this polynomial. There seem to be large regions of non-convergence. Changes of up to 1e_5 in any of the constants still fail to converge. The point seems to oscillate in a wide range but doesn't head toward any solution. In the implementation the initial guess is always 0j0. I don't see why this would fail. If anyone on this list can help, or knows someone who can help, I'd appreciate suggestions. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] p. _78 _1 0 0 0 1
That might well be what I'm seeing. The J implementation tries Laguerre, and if it fails perturbs the polynomial by 1e_12 in the leading coefficient. Do you think it would be better if instead I retried with a random starting point? I haven't checked for what the region of convergence of the starting point is. hhr On 2/4/2023 9:55 PM, Marshall Lochbaum wrote: Tried out my own Laguerre implementation from here: https://github.com/mlochbaum/bqn-libs/blob/master/polynomial.bqn#L80-L113 I remember I used J as a reference for this, but I think I ended up following this one in Julia: https://github.com/giordano/PolynomialRoots.jl/blob/master/src/PolynomialRoots.jl#L255 With the starting point at 0 it converges, but only with a few random adjustments from this line: { 0=jump_i|i ? root +↩ dx × Jump i÷jump_i ;@} Here Jump i÷jump_i just ignores the argument and produces a random float, ?0 in J (Julia has a table to avoid computing one). Removing this, I see a small region of non-convergence around 0, radius between 0.1 and 0.2. I suppose this isn't what you get? Marshall On Sat, Feb 04, 2023 at 08:34:46PM -0500, Henry Rich wrote: Somehow I lost the original post. For some reason Laguerre's method doesn't converge for this polynomial. There seem to be large regions of non-convergence. Changes of up to 1e_5 in any of the constants still fail to converge. The point seems to oscillate in a wide range but doesn't head toward any solution. In the implementation the initial guess is always 0j0. I don't see why this would fail. If anyone on this list can help, or knows someone who can help, I'd appreciate suggestions. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
[Jprogramming] p. _78 _1 0 0 0 1
Somehow I lost the original post. For some reason Laguerre's method doesn't converge for this polynomial. There seem to be large regions of non-convergence. Changes of up to 1e_5 in any of the constants still fail to converge. The point seems to oscillate in a wide range but doesn't head toward any solution. In the implementation the initial guess is always 0j0. I don't see why this would fail. If anyone on this list can help, or knows someone who can help, I'd appreciate suggestions. Henry Rich -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Crash with p.
These crash for me too. I have fixed the crash, which now produces a stack error instead. Sorry I can't give you the right answer. I'll look again after the 9.04 final release is out. Or maybe Elijah will come up with something. Henry Rich On 2/3/2023 11:34 PM, Schmidt-Gröttrup, Markus wrote: A numerical error crashes J p. _1E10 _1 0 0 1 works p. _77 _1 0 0 0 1 works p. _78 _1 0 0 0 1 crashes p. _14 _1 0 0 0 0 1 works p. _15 _1 0 0 0 0 1 crashes p. _8 _1 0 0 0 0 0 1 crashes p. _7 _1 0 0 0 0 0 1 works Version used: J807/j64/windows Greetings, Markus -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Version 9 sorting anomaly? (was: Re: Unexpected results (a bug?) in version 9 with some cases of cut (subarray))
This is so hard to measure! What's a reasonable reference system? The last time I measured, radixsort and mergesort had sizes where they were better. Now, on my Alder Lake CPU, quicksort beats the lot, at all sizes, integer and float. I don't see why it changed so much. There is still a sizable niche for small-range integer sort at all lengths, but the range decreases with length. Henry Rich On 2/3/2023 9:59 PM, Marshall Lochbaum wrote: In case it helps, I took the following measurement with bencharray. Looks like the parts other than those plateaus in the middle have gotten faster since 9.03, although they were still steps up before. The input ranges from -2^31 to 1-~2^31. https://raw.githubusercontent.com/gist/mlochbaum/40952f8d28ef745dc2d83d8278908ca8/raw/sort-rand-i32-x-j.svg In the key, ∧ is /:~ and ⍋ is /: . Same for ∨ ⍒ in the other direction. Reproduce with https://github.com/mlochbaum/bencharray and the following command; requires Unix and a BQN install and takes a minute or two to run. Output in output/plot/sort-rand-i32-x-j.svg . $ ./benchmark.bqn all j sort-rand-i32 Marshall On Fri, Feb 03, 2023 at 06:08:32PM -0500, Henry Rich wrote: Integer sort chooses between 4 algorithms based on timings we make every now and then. It's been a few years since we tuned it. 10 integers or more uses mergesort; 5-9 uses radixsort. It looks like I'd better retune that. Thanks for the tip. Henry Rich On 2/3/2023 5:01 PM, vadim wrote: So I tried to begin to implement "split into small sub-tasks", but got stuck before any meaningful step, at what may be another version 9 issue (?) Though I remember " DO NOT give an x argument to 6!:2", in tests below there is x argument to catch solid time. Otherwise, I could cut 10^7 numbers into ~100 ranges to sort each (closer to my real task), then there will be no x argument, with approx. the same "solid" time difference caught (decimal point moved to the right 2 places of course), but cutting would mask the real issue. 100 (6!:2) '/:~ nn' [ nn =: ? N $ 10^9 [ N =: 10 0.00263482 100 (6!:2) '/:~ nn' [ nn =: ? N $ 10^9 [ N =: 9 0.0073261 100 (6!:2) '}./:~ nn,_1' [ nn =: ? N $ 10^9 [ N =: 9 0.00298486 If I reboot into Linux, it's not 3x, but 4x difference between tests 1 and 2. Test 3 is like ridiculous advice "don't sort 9 (nor 99000, perhaps) numbers; instead pad with throw-away values to 10^5 numbers. I hope my result is not CPU-model specific, and you can observe something similar. No issue in 8.07. Best regards, Vadim On Fri, Jan 27, 2023 at 6:18 PM Henry Rich wrote: J9.04 is frozen for the release, but J9.05 will follow. This thread has convinced me that sorting large arrays can be greatly improved by multithreading, and also that I can reduce the threading overhead. Henry Rich On 1/27/2023 6:07 AM, vadim wrote: What result do you get when you use this syntax? "Don't use master thread, use worker threads only", correct? So, I'm allocating 3 workers for 4 equal pieces of work; 3 workers finish doing their task each, then 2 of them are idle, and 1 alone does the 4th part? Interestingly, with literals I get predictable time increase from ~400 ms to ~650 ms. Which concurs, more or less. With integers, I get the same ~440 ms. How very strange. And it's the same ~420 ... 440 ms if I cut ints into 2 or 3 parts (master thread is idle then). - I don't know if "parallelizable primitives" (including "sort") will arrive with 9.04 release, and maybe what follows was already mentioned in community, but with sorting literals there's effective and very lazy way to gain speed through using threads as they are implemented now: (6!:2) '/:~ lits' 1.37036 (6!:2) '/:~ ;cut_by /:~t.(0$0);.0 lits' 0.665364 1 T. '' 3 - Henry, I only have shallow understanding, my practical point of view was "try to divide work into preferably large and easy to manage parts, then oversee the whole gang of workers are busy and none of them slacks". Thank you very much for the detailed explanation, this cutting into very small pieces is new to me, I'll now see if I can implement it in practice. Sorting is only part of a larger whole; it's just that I noticed interesting results while experimenting. Best regards, Vadim On Fri, Jan 27, 2023 at 12:11 AM Ak O wrote: Hi Vadim, What result do you get when you use this syntax? ; cut_by /:~t.(<'worker';1);.0 ints Ak. On Thu., Jan. 26, 2023, 08:46 Henry Rich, wrote: 1. Make sure you turn off all browsers etc. when you time multrithreaded code. 2. DO NOT give an x argument to 6!:2. Repeated execution of the same sentence may tend to migrate values into the core they will be used in, which will underestimate the time required for a single run. If you have to time anything complicated you may have to put in your own timing points. 3. 'Thread overhead' is
Re: [Jprogramming] File Operations -> JMF Alternative
If anyone think NuVoc buries a key issue, they are encouraged to add to the information to NuVoc. I don't mean Raul. Raul knows this better than anyone and has put a lot of time into all aspects of J. Others should accept that the old documentation isn't going to change and if NuVoc is deficient, please help make it better. There are a few places - sparse matrix, symbols, u:, some foreigns - where the old docs have tables of detail that haven't been copied over into NuVoc. We would be grateful for any work undertaken in this area. Even just linking NuVoc to the Dictionary page with the detail would be helpful. I just noticed that some kind person put edit handles into the Foreigns page so you don't have to scroll through the whole page. Thanks! Henry Rich On 2/4/2023 2:38 AM, Raul Miller wrote: I guess you might want https://code.jsoftware.com/wiki/Vocabulary/Foreigns#m3 which has a link to the page sort of buried part way down https://code.jsoftware.com/wiki/Vocabulary/bangco Personally, I still prefer the old documentation, like https://www.jsoftware.com/help/dictionary/dx003.htm because of the tendency of NuVoc to bury key issues. -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Version 9 sorting anomaly? (was: Re: Unexpected results (a bug?) in version 9 with some cases of cut (subarray))
Integer sort chooses between 4 algorithms based on timings we make every now and then. It's been a few years since we tuned it. 10 integers or more uses mergesort; 5-9 uses radixsort. It looks like I'd better retune that. Thanks for the tip. Henry Rich On 2/3/2023 5:01 PM, vadim wrote: So I tried to begin to implement "split into small sub-tasks", but got stuck before any meaningful step, at what may be another version 9 issue (?) Though I remember " DO NOT give an x argument to 6!:2", in tests below there is x argument to catch solid time. Otherwise, I could cut 10^7 numbers into ~100 ranges to sort each (closer to my real task), then there will be no x argument, with approx. the same "solid" time difference caught (decimal point moved to the right 2 places of course), but cutting would mask the real issue. 100 (6!:2) '/:~ nn' [ nn =: ? N $ 10^9 [ N =: 10 0.00263482 100 (6!:2) '/:~ nn' [ nn =: ? N $ 10^9 [ N =: 9 0.0073261 100 (6!:2) '}./:~ nn,_1' [ nn =: ? N $ 10^9 [ N =: 9 0.00298486 If I reboot into Linux, it's not 3x, but 4x difference between tests 1 and 2. Test 3 is like ridiculous advice "don't sort 9 (nor 99000, perhaps) numbers; instead pad with throw-away values to 10^5 numbers. I hope my result is not CPU-model specific, and you can observe something similar. No issue in 8.07. Best regards, Vadim On Fri, Jan 27, 2023 at 6:18 PM Henry Rich wrote: J9.04 is frozen for the release, but J9.05 will follow. This thread has convinced me that sorting large arrays can be greatly improved by multithreading, and also that I can reduce the threading overhead. Henry Rich On 1/27/2023 6:07 AM, vadim wrote: What result do you get when you use this syntax? "Don't use master thread, use worker threads only", correct? So, I'm allocating 3 workers for 4 equal pieces of work; 3 workers finish doing their task each, then 2 of them are idle, and 1 alone does the 4th part? Interestingly, with literals I get predictable time increase from ~400 ms to ~650 ms. Which concurs, more or less. With integers, I get the same ~440 ms. How very strange. And it's the same ~420 ... 440 ms if I cut ints into 2 or 3 parts (master thread is idle then). - I don't know if "parallelizable primitives" (including "sort") will arrive with 9.04 release, and maybe what follows was already mentioned in community, but with sorting literals there's effective and very lazy way to gain speed through using threads as they are implemented now: (6!:2) '/:~ lits' 1.37036 (6!:2) '/:~ ;cut_by /:~t.(0$0);.0 lits' 0.665364 1 T. '' 3 - Henry, I only have shallow understanding, my practical point of view was "try to divide work into preferably large and easy to manage parts, then oversee the whole gang of workers are busy and none of them slacks". Thank you very much for the detailed explanation, this cutting into very small pieces is new to me, I'll now see if I can implement it in practice. Sorting is only part of a larger whole; it's just that I noticed interesting results while experimenting. Best regards, Vadim On Fri, Jan 27, 2023 at 12:11 AM Ak O wrote: Hi Vadim, What result do you get when you use this syntax? ; cut_by /:~t.(<'worker';1);.0 ints Ak. On Thu., Jan. 26, 2023, 08:46 Henry Rich, wrote: 1. Make sure you turn off all browsers etc. when you time multrithreaded code. 2. DO NOT give an x argument to 6!:2. Repeated execution of the same sentence may tend to migrate values into the core they will be used in, which will underestimate the time required for a single run. If you have to time anything complicated you may have to put in your own timing points. 3. 'Thread overhead' is more than just data movement. It includes time required to lock variable-name lookups and contention for D3$. The sort of 8-byte literals uses a merge sort IIRC, while the sort of integers uses a lovingly-coded quicksort. The quicksort is faster, as you can see. Mergesort is very cache-friendly: it reads and writes to memory sequentially. Quicksort hops around, storing single words into two different streams. On a single thread that doesn't matter much, but with multiple threads and arguments far larger than D3$, the writing spills to DRAM: mergesort needs only one open DRAM page per thread while quicksort needs two per thread. That will have to make a difference; how much I don't know. 4. If you want to split sorting into tasks, split it so that each task fits into D2$ of a core. With 10M numbers (80MB) and a machine with 1MB D2$, let each task have 125K numbers. Experiment with smaller blocks. When you have the right size, the thread overhead will be comparable to the time spent making two copies of the whole array. 5. If you find that you can reduce the overhead that far, we could have a faster way to sort in J using multithreads: split the array int
Re: [Jprogramming] Unexpected results (a bug?) in version 9 with some cases of cut (subarray)
J9.04 is frozen for the release, but J9.05 will follow. This thread has convinced me that sorting large arrays can be greatly improved by multithreading, and also that I can reduce the threading overhead. Henry Rich On 1/27/2023 6:07 AM, vadim wrote: What result do you get when you use this syntax? "Don't use master thread, use worker threads only", correct? So, I'm allocating 3 workers for 4 equal pieces of work; 3 workers finish doing their task each, then 2 of them are idle, and 1 alone does the 4th part? Interestingly, with literals I get predictable time increase from ~400 ms to ~650 ms. Which concurs, more or less. With integers, I get the same ~440 ms. How very strange. And it's the same ~420 ... 440 ms if I cut ints into 2 or 3 parts (master thread is idle then). - I don't know if "parallelizable primitives" (including "sort") will arrive with 9.04 release, and maybe what follows was already mentioned in community, but with sorting literals there's effective and very lazy way to gain speed through using threads as they are implemented now: (6!:2) '/:~ lits' 1.37036 (6!:2) '/:~ ;cut_by /:~t.(0$0);.0 lits' 0.665364 1 T. '' 3 - Henry, I only have shallow understanding, my practical point of view was "try to divide work into preferably large and easy to manage parts, then oversee the whole gang of workers are busy and none of them slacks". Thank you very much for the detailed explanation, this cutting into very small pieces is new to me, I'll now see if I can implement it in practice. Sorting is only part of a larger whole; it's just that I noticed interesting results while experimenting. Best regards, Vadim On Fri, Jan 27, 2023 at 12:11 AM Ak O wrote: Hi Vadim, What result do you get when you use this syntax? ; cut_by /:~t.(<'worker';1);.0 ints Ak. On Thu., Jan. 26, 2023, 08:46 Henry Rich, wrote: 1. Make sure you turn off all browsers etc. when you time multrithreaded code. 2. DO NOT give an x argument to 6!:2. Repeated execution of the same sentence may tend to migrate values into the core they will be used in, which will underestimate the time required for a single run. If you have to time anything complicated you may have to put in your own timing points. 3. 'Thread overhead' is more than just data movement. It includes time required to lock variable-name lookups and contention for D3$. The sort of 8-byte literals uses a merge sort IIRC, while the sort of integers uses a lovingly-coded quicksort. The quicksort is faster, as you can see. Mergesort is very cache-friendly: it reads and writes to memory sequentially. Quicksort hops around, storing single words into two different streams. On a single thread that doesn't matter much, but with multiple threads and arguments far larger than D3$, the writing spills to DRAM: mergesort needs only one open DRAM page per thread while quicksort needs two per thread. That will have to make a difference; how much I don't know. 4. If you want to split sorting into tasks, split it so that each task fits into D2$ of a core. With 10M numbers (80MB) and a machine with 1MB D2$, let each task have 125K numbers. Experiment with smaller blocks. When you have the right size, the thread overhead will be comparable to the time spent making two copies of the whole array. 5. If you find that you can reduce the overhead that far, we could have a faster way to sort in J using multithreads: split the array into as many pieces as needed and sort them efficiently in threads, then transfer the data back to the master thread which merges the ordered strings. The transfer back to the master thread is unavoidable, but the time required to merge (a reheaping operation) would be completely hidden under the transfer time. 6. Currently, starting a thread realizes any virtual argument in the master thread. It would be better to realize it in the worker thread where the data is needed. Henry Rich On 1/25/2023 6:11 PM, vadim wrote: Thank you for fixing the issue and for explanation. I would appreciate it if you could look into the performance issue I'm observing with my multi-threaded example (reduced to uselessness for sake of presentation, though). I will of course accept "that's how things are with CPUs/memory" and adjust expectations accordingly, and I understand results depend on hardware and dataset very much. Too small a chance it's J issue. The question concerns sorting data (I'm not doing the '+/' in threads :)). I have 4 cores CPU, so I start 3 additional threads: {{ for. i. 3 do. 0 T. 0 end. }} '' Suppose I have literal data, 10 million rows 8 bytes each: lits =: a. {~ ? ((1 * 10^7), 8) $ 256 q =: >. -: -: # lits cut_by =: q ,:~ "0 q * i. 4 quarter =: q {. lits 4 (6!:2) '/:~ lits' 1.37698 4 (6!:2) '/:~ quarter' 0.308181 4 (6!:2) '; cut_by /:~t.(0$0);.0 lits' 0.414603 Excellent, times I see match nicely, I understa
Re: [Jprogramming] Unexpected results (a bug?) in version 9 with some cases of cut (subarray)
1. Make sure you turn off all browsers etc. when you time multrithreaded code. 2. DO NOT give an x argument to 6!:2. Repeated execution of the same sentence may tend to migrate values into the core they will be used in, which will underestimate the time required for a single run. If you have to time anything complicated you may have to put in your own timing points. 3. 'Thread overhead' is more than just data movement. It includes time required to lock variable-name lookups and contention for D3$. The sort of 8-byte literals uses a merge sort IIRC, while the sort of integers uses a lovingly-coded quicksort. The quicksort is faster, as you can see. Mergesort is very cache-friendly: it reads and writes to memory sequentially. Quicksort hops around, storing single words into two different streams. On a single thread that doesn't matter much, but with multiple threads and arguments far larger than D3$, the writing spills to DRAM: mergesort needs only one open DRAM page per thread while quicksort needs two per thread. That will have to make a difference; how much I don't know. 4. If you want to split sorting into tasks, split it so that each task fits into D2$ of a core. With 10M numbers (80MB) and a machine with 1MB D2$, let each task have 125K numbers. Experiment with smaller blocks. When you have the right size, the thread overhead will be comparable to the time spent making two copies of the whole array. 5. If you find that you can reduce the overhead that far, we could have a faster way to sort in J using multithreads: split the array into as many pieces as needed and sort them efficiently in threads, then transfer the data back to the master thread which merges the ordered strings. The transfer back to the master thread is unavoidable, but the time required to merge (a reheaping operation) would be completely hidden under the transfer time. 6. Currently, starting a thread realizes any virtual argument in the master thread. It would be better to realize it in the worker thread where the data is needed. Henry Rich On 1/25/2023 6:11 PM, vadim wrote: Thank you for fixing the issue and for explanation. I would appreciate it if you could look into the performance issue I'm observing with my multi-threaded example (reduced to uselessness for sake of presentation, though). I will of course accept "that's how things are with CPUs/memory" and adjust expectations accordingly, and I understand results depend on hardware and dataset very much. Too small a chance it's J issue. The question concerns sorting data (I'm not doing the '+/' in threads :)). I have 4 cores CPU, so I start 3 additional threads: {{ for. i. 3 do. 0 T. 0 end. }} '' Suppose I have literal data, 10 million rows 8 bytes each: lits =: a. {~ ? ((1 * 10^7), 8) $ 256 q =: >. -: -: # lits cut_by =: q ,:~ "0 q * i. 4 quarter =: q {. lits 4 (6!:2) '/:~ lits' 1.37698 4 (6!:2) '/:~ quarter' 0.308181 4 (6!:2) '; cut_by /:~t.(0$0);.0 lits' 0.414603 Excellent, times I see match nicely, I understand there's overhead with threads. Next, there are 10 millions of 8-byte integers: ints =: ? (1 * 10^7) $ (10^18) q =: >. -: -: # ints cut_by =: q ,:~ "0 q * i. 4 quarter =: q {. ints 4 (6!:2) '/:~ ints' 0.561057 4 (6!:2) '/:~ quarter' 0.124735 4 (6!:2) '; cut_by /:~t.(0$0);.0 ints' 0.441807 And I don't like this third time. There's roughly the same amount of data for "threads overhead". My expectation for this result was approx. 150-200 ms or so. In fact, looking at 415 ms for literals and 442 ms for numbers irked me into temptation: head =. (3&(3!:4) 16be2), ,|."1 (3&(3!:4)"0) 4,q,1,q _8 ]\ a. i. head 226 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 38 37 160 0 0 0 0 0 0 0 1 0 0 0 0 0 38 37 160 to_bytes =: 5&}. @: (_8&(]\)) @: (2&(3!:1)) from_bytes =: (3!:2) @: (head&,) @: , (from_bytes /:~ to_bytes quarter) -: (/:~ quarter) NB. sane still? 1 4 (6!:2) ';cut_by (from_bytes @: /:~ @: to_bytes)t.(0$0);.0 ints' 0.51177 Ah, it didn't work. But perhaps it could with certain data, CPU model, number of cores? So my question is if you could confirm that it (slower than I expected speed with numerical sort in threads) is neither J issue, nor 't.', nor '/:~'. Sorry if I wasted your time. Best regards, Vadim On Wed, Jan 25, 2023 at 8:02 PM Henry Rich wrote: Fixed for the release. Thanks for the clear report. The problem was specific to the forms you mentioned. Workaround: use < @: ((+/) @:]) instead of < @: (+/) @:] The form <@:f is given special treatment. Your form was incorrectly being given that treatment. If t. in cut is not meeting your expectations, perhaps you should adjust your expectations. Verbs like (+/) will not benefit from threading in most cases, and may slow down considerably. +/;.0 might be even worse. Why? Because +/ is totally limited by the speed of reading from
Re: [Jprogramming] Unexpected results (a bug?) in version 9 with some cases of cut (subarray)
Fixed for the release. Thanks for the clear report. The problem was specific to the forms you mentioned. Workaround: use < @: ((+/) @:]) instead of < @: (+/) @:] The form <@:f is given special treatment. Your form was incorrectly being given that treatment. If t. in cut is not meeting your expectations, perhaps you should adjust your expectations. Verbs like (+/) will not benefit from threading in most cases, and may slow down considerably. +/;.0 might be even worse. Why? Because +/ is totally limited by the speed of reading from memory. If the data fits in level-2 data cache (D2$) many cores are no faster than one. In fact they are much slower, because only one core has the data in D2$. The rest have to transfer the data from the bottom of the ocean (i. e. from the core with the data through D3$) or from the moon (SDRAM). They are spending their time waiting for responses from memory. +/;.0 creates a virtual block for each section and passes that to +/ . There is no need to move the data except for the reading required by +/ . If you run the +/ in a thread, the virtual block must be realized with an explicit copy from the bottom of the ocean. That doesn't add much, because once the copy is made the data will be in D2$ of the receiving core, but it is a small slowdown. A thread needs to be able to run in its own core until it has done reads+writes to D1$/D2$ at least, say, 100 times the size of its arguments+result. +/ . * is a perfect example. On large matrices the arguments are cycled through repeatedly. Henry Rich On 1/25/2023 7:08 AM, vadim wrote: Hi, please consider this: ((0,:2),:(2,:2)) (< @: +: @: ]);.0 i. 4 +---+---+ |0 1|2 3| +---+---+ ((0,:2),:(2,:2)) (< @: (+/) @: ]);.0 i. 4 +---+---+ |0 1|2 3| +---+---+ ((0,:2),:(2,:2)) (< @: (\:~) @: ]);.0 i. 4 +---+---+ |0 1|2 3| +---+---+ No issues in 8.07; and a bug (that's what I'd call it) in 9.03 and 9.04. Looks like it happens if the left arg has multiple ranges; and a verb to apply is composed with "same" and "box" verbs as first and last in sequence. But it's at 1st glance only. Sometimes omitting parentheses would help (which clearly means parsing issue?). All these produce expected output: (2,:2) (< @: +: @: ]);.0 i. 4 +---+ |4 6| +---+ ((0,:2),:(2,:2)) (] @: +: @: ]);.0 i. 4 0 2 4 6 ((0,:2),:(2,:2)) (< @: +/ @: ]);.0 i. 4 +-+-+ |1|5| +-+-+ (0,:2) (< @: (\:~) @: ]);.0 i. 4 +---+ |1 0| +---+ ((0,:2),:(2,:2)) (] @: (\:~) @: ]);.0 i. 4 1 0 3 2 ((0,:2),:(2,:2)) (< @: (\:~));.0 i. 4 +---+---+ |1 0|3 2| +---+---+ While "why would you want to use the ']' here?" would be reasonable to ask, but, in the end, syntax is either correct or not. In fact, I was testing all kinds of different constructs investigating why multi-threaded operation (with "t.") on subarrays is so much slower than expected, although it's perhaps totally unrelated to what's discovered above. Best regards, Vadim -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Verbs returning verbs
I'm glad to hear this. None of the other replies has engaged with my proposal, instead saying things like 'ARs are nouns and so can't be first-class verbs'. This hits the nail on the thumb. What's important is whether you can pass function A into function B and have B call A: whatever syntax is required is a detail. We have long been able to pass ARs into explicit definitions, but the tacit language needs additional features, which I think my proposal provides. The other strain of response to my proposal essentially ignored it and instead expatiated on the advantages of Cloak, while ignoring the fact that if not used in a restricted way it will crash the system: a serious defect. Henry Rich On 1/22/2023 8:51 PM, Raul Miller wrote: After thinking about this (and sleeping on it), I think this is a good idea. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Closures; WAS: Verbs returning verbs
I don't see that name_.. has any of the defects you see, except that it IS butt-ugly. Performance is not to be dismissed. You are talking about the parser, which for much user code is the heaviest-used part of the system. Ordinary local-symbol lookups take two reads from memory. If you add a table search to that you have more than doubled the time spent in parsing. I'm retiring from this thread because I don't know what a lexical closure is or why I ought to know. I say this with the greatest respect. If you think I'm missing something important, please explain it to me (privately). Henry Rich On 1/19/2023 12:16 AM, Elijah Stone wrote: I don't see why name_. is preferable to lexical closures. It seems more difficult to use and complicated to describe; not significantly easier to implement; and it doesn't nest. Leaving aside performance (which can be resolved), I don't like the semantics of name_.. . Its sole virtue is that it admits corecursion. On Wed, 18 Jan 2023, Henry Rich wrote: You are addressing a need, I admit, but one that is fairly rare, and the proposed change is drastic IMO. The need is for something like lexical scope, when function g can refer to a local name in function f. Rather than remembering the environment, suppose we added some syntax if g to indicate references into f? Some decorated g, say name_., would mean 'name when g was defined' and would be replaced in the definition of g by its current value in f (or higher). Some other decorated g, say name_.., would mean 'name as found in f when name_.. is stacked'. I would vote against having name_.. because it would slow down name lookup. Currently, lookups of private names do not require locking the name table, since there can be no other lookup into it. That would be lost. name_. OTOH seems like a welcome addition. Unfortunately I have much more often wanted name_.. . Henry Rich On 1/17/2023 10:58 PM, Elijah Stone wrote: Basically, yes. It's interesting that you refer to them that way; it brings to mind locales, which are another type of namespace, and suggests the possibility of unifying lexical environments with locales. I think doing that would be a bad idea, though, because locales are shared mutable state, and it would be good to have less of that rather than more. Hence, my proposal applies only to lexical scopes. The idea is that, if I have something like: f=. {{ a=. 5 b=. 6 g=. {{ ... a ... }} a=. 7 ... }} When g (or, rather, the verb it denotes) is created, it will remember and carry around the lexical environment in which it was created, which includes an association between a and 5. (Since g refers to a, we say that it 'closes over' it. The term 'closure' comes from graph theory.) This association is frozen at the time g is created; hence, it never sees a=5. The environment is manifest in the AR as a list of key-value associations; users can twiddle or create their own environments, but should not generally have much call to. Obviously, this comprises a break to compatibility, but the fallout seems fairly minor. Such name punning would be quite confusing. Since closure only applies to lexical variables, this breaks no use of globals. EG the following, at global scope: a=: 5 fn=: {{ ... a ... }} a=: 7 Will work just the same as it ever did. A question: should g close over b? It is not referred to directly in g, but the latter might construct references to b using "., or a user might ask for it when debugging. I vote no, because of the potential for space leaks. g can include a dummy reference to b, if it really wants; and perhaps a global toggle can be added for debugging purposes. (This also relates to my comment in github issue #153.) What say? -E On Tue, 17 Jan 2023, Henry Rich wrote: Is it about namespaces then? That is indeed a vexed question. I will take this under advisement. I will need more help I'm sure. Henry Rich On 1/17/2023 10:15 PM, Elijah Stone wrote: It is the other way around--lack of closures means we must write _more_ tacit code, not less. E.G.: {{ a=. something {{ something referring to a }} A y NB. doesn't work }} Whereas: {{ a=. something (something referring to a) A y NB. works }} I am proposing a mechanism to make the former work (among other things). On Tue, 17 Jan 2023, Henry Rich wrote: I don't follow any of this thread, because I don't understand what is missing from standard J. I find J adequate for everything I want to do. What am I missing? I can see that if you want to write all-tacit code you have trouble if you need to feed a verb result into a modifier. Suppose though that I am content with writing explicit definitions. What do I need beyond the standard language, and for what use case? Henry Rich On 1/17/2023 9:23 PM, Elijah Stone wrote: (Curried modifiers, as you say, are a solution, but, again, another half-solution.) On Tue, 1
Re: [Jprogramming] Closures; WAS: Verbs returning verbs
Read- and write-locks as you describe are what we use for public locales. Each lock requires a RFO cycle, plus more if the lock is contended. Private namespaces require no lock, since nothing can ever contend. We would have to add something to those paths. Those paths are carefully timed and any change that slows them down would have to be justified. hhr On 1/18/2023 1:49 PM, Raul Miller wrote: Note that, conceptually, at least, your proposed name_.. might not need full locking of all name lookups. Such locking is technically only needed when an execution containing the specific name has been parsed. So, conceptually speaking, most name lookups would only need a "read lock" (which can be shared by many readers) except for names marked under a parse activated "write lock" (which must be unique). Once a name is marked with a non-zero _.. count that name lookup would need a unique write lock before its value could be relied on, but if that's needed for correctness, it would be a worthwhile cost. When the parse is discarded it would need to decrement any _.. counts it had. Note that this would mean that shadow names would need to be retained even after a name was erased, so erase (and assignment and the copath mechanism) would also need some additional locking logic which is cognizant of the copath of the namespace which has those shadow names (pushing the lock count down the path if a more global name exists, subtracting the lock count when the shadow is no longer cast). In principle those read locks might be negligible but that's an uninformed judgement on my part. I don't actually know how slow they would wind up being... Elijah, Henry: Does this sound like a plausible mechanism to you? Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Closures; WAS: Verbs returning verbs
You are addressing a need, I admit, but one that is fairly rare, and the proposed change is drastic IMO. The need is for something like lexical scope, when function g can refer to a local name in function f. Rather than remembering the environment, suppose we added some syntax if g to indicate references into f? Some decorated g, say name_., would mean 'name when g was defined' and would be replaced in the definition of g by its current value in f (or higher). Some other decorated g, say name_.., would mean 'name as found in f when name_.. is stacked'. I would vote against having name_.. because it would slow down name lookup. Currently, lookups of private names do not require locking the name table, since there can be no other lookup into it. That would be lost. name_. OTOH seems like a welcome addition. Unfortunately I have much more often wanted name_.. . Henry Rich On 1/17/2023 10:58 PM, Elijah Stone wrote: Basically, yes. It's interesting that you refer to them that way; it brings to mind locales, which are another type of namespace, and suggests the possibility of unifying lexical environments with locales. I think doing that would be a bad idea, though, because locales are shared mutable state, and it would be good to have less of that rather than more. Hence, my proposal applies only to lexical scopes. The idea is that, if I have something like: f=. {{ a=. 5 b=. 6 g=. {{ ... a ... }} a=. 7 ... }} When g (or, rather, the verb it denotes) is created, it will remember and carry around the lexical environment in which it was created, which includes an association between a and 5. (Since g refers to a, we say that it 'closes over' it. The term 'closure' comes from graph theory.) This association is frozen at the time g is created; hence, it never sees a=5. The environment is manifest in the AR as a list of key-value associations; users can twiddle or create their own environments, but should not generally have much call to. Obviously, this comprises a break to compatibility, but the fallout seems fairly minor. Such name punning would be quite confusing. Since closure only applies to lexical variables, this breaks no use of globals. EG the following, at global scope: a=: 5 fn=: {{ ... a ... }} a=: 7 Will work just the same as it ever did. A question: should g close over b? It is not referred to directly in g, but the latter might construct references to b using "., or a user might ask for it when debugging. I vote no, because of the potential for space leaks. g can include a dummy reference to b, if it really wants; and perhaps a global toggle can be added for debugging purposes. (This also relates to my comment in github issue #153.) What say? -E On Tue, 17 Jan 2023, Henry Rich wrote: Is it about namespaces then? That is indeed a vexed question. I will take this under advisement. I will need more help I'm sure. Henry Rich On 1/17/2023 10:15 PM, Elijah Stone wrote: It is the other way around--lack of closures means we must write _more_ tacit code, not less. E.G.: {{ a=. something {{ something referring to a }} A y NB. doesn't work }} Whereas: {{ a=. something (something referring to a) A y NB. works }} I am proposing a mechanism to make the former work (among other things). On Tue, 17 Jan 2023, Henry Rich wrote: I don't follow any of this thread, because I don't understand what is missing from standard J. I find J adequate for everything I want to do. What am I missing? I can see that if you want to write all-tacit code you have trouble if you need to feed a verb result into a modifier. Suppose though that I am content with writing explicit definitions. What do I need beyond the standard language, and for what use case? Henry Rich On 1/17/2023 9:23 PM, Elijah Stone wrote: (Curried modifiers, as you say, are a solution, but, again, another half-solution.) On Tue, 17 Jan 2023, Raul Miller wrote: Here, I suspect that you're only getting noun values in your closure -- you'll have to sprinkle those noun references with something like `:6 if you want anything else. That's probably not a huge problem. But, thinking about this, personally I'm not seeing a lot of motivation for this approach, either. (What problems would this solve? I'm sure there are some great motivating examples out there. And closures certainly have a lot of popularity. But... position in a list can be thought of as being conceptually analogous to a variable, so it should be apparent that we already have some support for the algorithmic role of closures.) (I should perhaps also note, here, that conjunctions and adverbs which have verb results are self-currying.) Anyways... I'm not thinking particularly deep thoughts here -- I'm just reflexively reaching for motivating examples (which might assist in forming some of those sorts of thoughts). Thanks, -- Raul On Tue, Jan 17, 2023 at 7:01 PM Elijah