Re: [Jprogramming] (no subject)
Hi all ! a=: 2 5 7 f=: 1 : '/:~(#: }. i. 2 ^ # y) ([: u/ #) /"1 y' + f a 2 5 7 7 9 12 14 * f a 2 5 7 10 14 35 70 Cheers, Erling On 2017-10-02 19:45, Erling Hellenäs wrote: Hi all! You don't want the combination of zero elements? a=: 2 5 7 /:~(#: i. 2 ^ # a) ([:+/#) /"1 1 a 0 2 5 7 7 9 12 14 /:~(#: i. 2 ^ # a) ([:*/#) /"1 1 a 1 2 5 7 10 14 35 70 Guess I could drop it. Cheers, Erling On 2017-10-02 18:49, Skip Cave wrote: Given a set of integers, what is the most concise and or efficient way to list the numbers along with the sum of all combinations of the numbers? the products of all combinations? for example: a =. 2 5 7 + f a NB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) 2 5 7 7 9 12 14 * f a NB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) 2 5 7 10 14 35 70 The function 'f' should work for any verb and any size right argument noun vector. Skip 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] (no subject)
http://code.jsoftware.com/wiki/Essays/Divisors What you have been asking for are computations on all possible subsets. When dealing with all possible subsets, start with the boolean matrix #:@i.@(2&^)@# . You can then do B +/ .* x for all sums or B */ . (^~) x for all products. Combinations are not the way to go because m comb n will get you the indices for the subsets of size m, whereas you want subsets of size 0, 1, ..., n. On Mon, Oct 2, 2017 at 1:03 PM, Skip Cavewrote: > My initial goal was to find all the divisors of a number, eg 100: > Get the prime factors: > q:100 > 2 2 5 5 > > Get all combinations of those prime factors (the power set) > > ps0 =: #:@i.@(2&^)@#<@#"1 _] > > ps0 q:100 > > ┌┬─┬─┬───┬─┬───┬───┬─┬─┬───┬───┬─┬───┬─┬─┬───┐ > > ││5│5│5 5│2│2 5│2 5│2 5 5│2│2 5│2 5│2 5 5│2 2│2 2 5│2 2 5│2 2 5 5│ > > └┴─┴─┴───┴─┴───┴───┴─┴─┴───┴───┴─┴───┴─┴─┴───┘ > > Get the products of each box: > > */ each ps0 q: 100 > > ┌─┬─┬─┬──┬─┬──┬──┬──┬─┬──┬──┬──┬─┬──┬──┬───┐ > > │1│5│5│25│2│10│10│50│2│10│10│50│4│20│20│100│ > > └─┴─┴─┴──┴─┴──┴──┴──┴─┴──┴──┴──┴─┴──┴──┴───┘ > > > Get the unique set of divisors and sort them: > > /:~ ~.>*/ each ps0 q:100 > > 1 2 4 5 10 20 25 50 100 > > > Now thanks to everyone's help, I can find all the divisors of any number: > > f=.3 :'/:~ ~.>*/ each ps0 q:y' > > f 110 > > 1 2 5 10 11 22 55 110 > > f 43 > > 1 43 > > f 444 > > 1 2 3 4 6 12 37 74 111 148 222 444 > > > Skip > > > > Skip Cave > Cave Consulting LLC > > On Mon, Oct 2, 2017 at 2:40 PM, Raul Miller wrote: > > > Perhaps this is closer to what you want? > > > > F=:1 :', u@> { (~. (u@#"0~ i.@>:)&.> #/.~) y' > > f=: /F > > > > *f 2 2 5 7 > > 1 7 5 35 2 14 10 70 4 28 20 140 > > +f 2 2 5 7 > > 0 7 5 12 2 9 7 14 4 11 9 16 > > > > I probably should just merge the two definitions together, but I think > > this works? > > > > (Note that I have sort of assumed that the verb argument to f is an > > associative verb. If you're doing something where that is not the > > case... well... I guess I would need more specification.) > > > > Thanks, > > > > -- > > Raul > > > > > > On Mon, Oct 2, 2017 at 3:17 PM, Skip Cave > wrote: > > > Sorry about the wrong terminology. What i meant was: > > > > > > Given a vector of random integers (there may be duplicates), what is > the > > > most concise and or efficient way to > > > generate a list of the numbers along with the sum of all combinations > of > > > the numbers in a single vector? How about the products of all > > > combinations? > > > > > > Skip Cave > > > Cave Consulting LLC > > > > > > On Mon, Oct 2, 2017 at 1:51 PM, Raul Miller > > wrote: > > > > > >> Prime factors of an integer are not, in the general case, a set. And > > >> you really should be careful to avoid specifying a set when what you > > >> want is not a set. > > >> > > >> You might be interested in > > >> https://rosettacode.org/wiki/Factors_of_an_integer#J ? > > >> > > >> That said, refinement is an important part of the specification > > >> process, so - since it seems you were looking for something different > > >> - maybe it's worth redoing the specification? > > >> > > >> Thanks, > > >> > > >> -- > > >> Raul > > >> > > >> > > >> On Mon, Oct 2, 2017 at 2:09 PM, Skip Cave > > wrote: > > >> > My original approach was even more naive than Marc's: > > >> > > > >> > NB. from Roger Hui's Combinations essay on the J website: > > >> > https://goo.gl/WL4nXn > > >> > > > >> > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this > > >> 'comb2' > > >> > > > >> > NB. I used this definition because I could cut & paste one line, and > > not > > >> > require an editor > > >> > > > >> > a =. 2 2 5 5 > > >> > > > >> > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > > >> > > > >> > 100 20 50 4 10 25 2 5 > > >> > > > >> > > > >> > I like to sort it: > > >> > > > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 > c > > 4){a > > >> > > > >> > 2 4 5 10 20 25 50 100 > > >> > > > >> > > > >> > The final goal of this exercise was to find all the divisors of an > > >> integer > > >> > (not just the prime divisors). > > >> > > > >> > > > >> > So you need to find the prime factors of the integer, for example > 100: > > >> > > > >> > > > >> > ]a =. q:100 > > >> > > > >> > 2 2 5 5 > > >> > > > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, > > |:(1 c > > >> 4){a > > >> > > > >> > 2 4 5 10 20 25 50 100 > > >> > > > >> > > > >> > So these are all the divisors of 100. > > >> > > > >> > > > >> > To use Raul's verb, it needs some mods. I can't do the unique until > > the > > >> > end, because prime factors of an integer are often duplicated. > > >> > > > >> > > > >> > F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's
Re: [Jprogramming] zmq - big step for J socket services
There is a different J code path with windows and linux, not to mention underlying system differences. I made a repeat run with (J session that had been dormant for a day and) my echo modification, and it (qrun) hung, on the last "end task", and presumably on the kill__c command. I've tried the various other zmq dlls, including debug releases, and they all crash eventually on qrun. An interesting feature about the crashes, the redefined echo has the same behaviour as in jconsole (the latter doesn't need "doevents" to print immediately) -- is that all of the crashes occur on the last "end task". From: bill lamTo: 'Pascal Jasmin' via Programming Sent: Monday, October 2, 2017 12:11 AM Subject: Re: [Jprogramming] zmq - big step for J socket services jconsole and jhs can not run wd commands and I don't think problem is qt related or can be solved by qt. I had tried commenting the line in jcs_lab.ijs 'must be < 20' assert y<20 also change 'e7' to 'e5' Then this sentence ran fine on linux64 jconsole intel core i-7 quad-core (hyperthread disabled) (qrun bind 99 99)^:10 '' Пт, 29 сен 2017, jprogramming написал(а): > > A solid accidental fix comes from changing echo: > > > echo_z_ =: (0 0 $1!:2&2)`(wd bind 'msgs' ] 0 0 $ 1!:2&2)@.IFQT > > the liberal amount of wd 'msgs' in qrun, seems to let the system (perhaps > down to zmq) catch up to the state it thinks it should be in. > > From: 'Pascal Jasmin' via Programming > To: "programm...@jsoftware.com" > Sent: Friday, September 29, 2017 3:50 PM > Subject: Re: [Jprogramming] zmq - big step for J socket services > > > > > > changing the kill verb to: > > kill=: 3 : 0 > access=: su > runa'exit 0' > killp PORT NB. new line. > destroy'' > i.0 0 > ) > > > helps with the sockets command consistently returning empty, and in general > lengthens the test lifetime but > > qrun 11 11 will still fail within 3 "reruns" > > (qrun modified to use e6 instead of e7 for convenience) > > windows 10 > > > > From: Eric Iverson > To: Programming forum > Sent: Friday, September 29, 2017 9:59 AM > Subject: Re: [Jprogramming] zmq - big step for J socket services > > > > When you get a server error, lse__c gives you the J error message. I think > this is covered in the lab and in the help. > > kill and related things depend on host services and that code is still a > bit rough and naive. It will be cleaned bup with experience or more > rigorous study. Problems in this area are do not indicate zmq problems per > se. > > Tracking down qrun hang would be worthwhile. Again, I will bet it has to do > with starting/tracking/killing tasks and not directly a zmq problem. > > On Thu, Sep 28, 2017 at 7:14 PM, 'Pascal Jasmin' via Programming < > programm...@jsoftware.com> wrote: > > > its working pretty well, > > > > A suggestion for generic "server error" would be to return the J error > > from the J server instead. Useful for the examples you are showing now. > > (basically show lse__ as client response) > > > > > > > > The labs and examples do eventually hang if repeated enough though. > > A repeated crash on the zmq lab occurs after the lines > > > > kill__c '' > > kill__d '' > > > > servers_jcs_ '' still shows the c port open 65201 > > > > then "jcst port" hangs. > > > > killp_jcs_ 65201 removes it from servers > > the kill__c command later in the lab does not crash. > > > > > > if qrun is repeated enough times, it will also hang the j session. > > > > From: Eric Iverson > > To: Programming forum > > Sent: Thursday, September 28, 2017 1:04 PM > > Subject: [Jprogramming] zmq - big step for J socket services > > > > > > > > New addons net/zmq and net/jcs are available. They require 806. > > > > > > The zmq addon has bindings between J and the zmq shared library. > > > > > > The jcs addon has J client/server tools built on the zmq request/reply > > > > pattern. > > > > > > These addons make it much easier and with far less code to provide > > > > high-performance, robust, and scalable socket services. > > > > > > Start with 806-beta-6 installed from the latest zip packages. Then be sure > > > > you have the > > > > latest base library and the net/zmq and net/jcs addons installed. > > > > > > An easy way to get started is to run the jcs lab. > > > > > > start J > > > >load'labs/labs' > > > >lab'~addons/net/jcs/jcs_lab.ijs' > > > > step through the lab > > > > > > The lab will let you know if you need to install zmq and where to look for > > > > info. > > > > > > Sharing zmq install hints in the forum could save others some trouble. > > > > > > *** > > > > Among other things, jcs makes it easy to
Re: [Jprogramming] (no subject)
f=.[:+/]*[:|:(2#~#)#:[:i.2^# f 2 5 7 0 7 5 12 2 9 7 14 g=.[:*/]^[:|:(2#~ #)#:[:i.2^# g 2 5 7 1 7 5 35 2 14 10 70 NB. I didn't check if this solution has already been offered. I just coded it. Den 21:40 mandag den 2. oktober 2017 skrev Raul Miller: Perhaps this is closer to what you want? F=:1 :', u@> { (~. (u@#"0~ i.@>:)&.> #/.~) y' f=: /F *f 2 2 5 7 1 7 5 35 2 14 10 70 4 28 20 140 +f 2 2 5 7 0 7 5 12 2 9 7 14 4 11 9 16 I probably should just merge the two definitions together, but I think this works? (Note that I have sort of assumed that the verb argument to f is an associative verb. If you're doing something where that is not the case... well... I guess I would need more specification.) Thanks, -- Raul On Mon, Oct 2, 2017 at 3:17 PM, Skip Cave wrote: > Sorry about the wrong terminology. What i meant was: > > Given a vector of random integers (there may be duplicates), what is the > most concise and or efficient way to > generate a list of the numbers along with the sum of all combinations of > the numbers in a single vector? How about the products of all > combinations? > > Skip Cave > Cave Consulting LLC > > On Mon, Oct 2, 2017 at 1:51 PM, Raul Miller wrote: > >> Prime factors of an integer are not, in the general case, a set. And >> you really should be careful to avoid specifying a set when what you >> want is not a set. >> >> You might be interested in >> https://rosettacode.org/wiki/Factors_of_an_integer#J ? >> >> That said, refinement is an important part of the specification >> process, so - since it seems you were looking for something different >> - maybe it's worth redoing the specification? >> >> Thanks, >> >> -- >> Raul >> >> >> On Mon, Oct 2, 2017 at 2:09 PM, Skip Cave wrote: >> > My original approach was even more naive than Marc's: >> > >> > NB. from Roger Hui's Combinations essay on the J website: >> > https://goo.gl/WL4nXn >> > >> > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this >> 'comb2' >> > >> > NB. I used this definition because I could cut & paste one line, and not >> > require an editor >> > >> > a =. 2 2 5 5 >> > >> > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a >> > >> > 100 20 50 4 10 25 2 5 >> > >> > >> > I like to sort it: >> > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a >> > >> > 2 4 5 10 20 25 50 100 >> > >> > >> > The final goal of this exercise was to find all the divisors of an >> integer >> > (not just the prime divisors). >> > >> > >> > So you need to find the prime factors of the integer, for example 100: >> > >> > >> > ]a =. q:100 >> > >> > 2 2 5 5 >> > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c >> 4){a >> > >> > 2 4 5 10 20 25 50 100 >> > >> > >> > So these are all the divisors of 100. >> > >> > >> > To use Raul's verb, it needs some mods. I can't do the unique until the >> > end, because prime factors of an integer are often duplicated. >> > >> > >> > F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's verb minus the >> initial >> > unique >> > >> > */F1 q:100 NB. we take the product >> > >> > 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100 >> > >> > ~.*/F1 q:100 NB. Now we take the unique >> > >> > 1 5 25 2 10 50 4 20 100 >> > >> > /:~~.*/F1 q:100 NB. Sort it to make it pretty >> > >> > 1 2 4 5 10 20 25 50 100 >> > >> > >> > Didn't really need the 1, but Raul likes the empty combination. >> > >> > >> > Now we put it all in one verb: >> > >> > >> > F2=. /:~~.*/F1 q: >> > >> > F2 100 >> > >> > |length error: F2 >> > >> > | F2 100 >> > >> > F2=. /:~~.*/F1 q:] >> > >> > F2 100 >> > >> > |domain error: F2 >> > >> > | F2 100 >> > >> > >> > So this is above my pay grade. I'll have to stick with my inline code: >> > >> > >> > /:~~.*/F1 q:110 >> > >> > 1 2 5 10 11 22 55 110 >> > >> > /:~~.*/F1 q:43 >> > >> > 1 43 >> > >> > /:~~.*/F1 q:45 >> > >> > 1 3 5 9 15 45 >> > >> > /:~~.*/F1 q:444 >> > >> > 1 2 3 4 6 12 37 74 111 148 222 444 >> > >> > >> > So I can find all the divisors of an integer. >> > >> > >> > Skip >> > >> > >> > >> > >> > >> > >> > Skip Cave >> > Cave Consulting LLC >> > >> > On Mon, Oct 2, 2017 at 12:15 PM, Marc Simpson wrote: >> > >> >> More naive than Raul's approach, first pass using the 'stats' lib: >> >> >> >> a=.2 5 7 >> >> require'stats' >> >> combv=: ] {~ (comb #@]) >> >> 3 combv a >> >> 2 5 7 >> >> 2 combv a >> >> 2 5 >> >> 2 7 >> >> 5 7 >> >> 1 combv a >> >> 2 >> >> 5 >> >> 7 >> >> combos=: (1 + i.@#) <@combv"0 1 ] >> >> combos a >> >> ┌─┬───┬─┐ >> >> │2│2 5│2 5 7│ >> >> │5│2 7│ │ >> >> │7│5 7│ │ >> >> └─┴───┴─┘ >> >> f=: 1 : ';u/"1 each combos y' >> >> +f a >> >> 2 5 7 7 9 12 14 >> >> *f a >> >> 2 5 7 10 14 35 70 >> >> >> >> /M >> >> >> >> On Mon, Oct 2, 2017
Re: [Jprogramming] (no subject)
My initial goal was to find all the divisors of a number, eg 100: Get the prime factors: q:100 2 2 5 5 Get all combinations of those prime factors (the power set) ps0 =: #:@i.@(2&^)@#<@#"1 _] ps0 q:100 ┌┬─┬─┬───┬─┬───┬───┬─┬─┬───┬───┬─┬───┬─┬─┬───┐ ││5│5│5 5│2│2 5│2 5│2 5 5│2│2 5│2 5│2 5 5│2 2│2 2 5│2 2 5│2 2 5 5│ └┴─┴─┴───┴─┴───┴───┴─┴─┴───┴───┴─┴───┴─┴─┴───┘ Get the products of each box: */ each ps0 q: 100 ┌─┬─┬─┬──┬─┬──┬──┬──┬─┬──┬──┬──┬─┬──┬──┬───┐ │1│5│5│25│2│10│10│50│2│10│10│50│4│20│20│100│ └─┴─┴─┴──┴─┴──┴──┴──┴─┴──┴──┴──┴─┴──┴──┴───┘ Get the unique set of divisors and sort them: /:~ ~.>*/ each ps0 q:100 1 2 4 5 10 20 25 50 100 Now thanks to everyone's help, I can find all the divisors of any number: f=.3 :'/:~ ~.>*/ each ps0 q:y' f 110 1 2 5 10 11 22 55 110 f 43 1 43 f 444 1 2 3 4 6 12 37 74 111 148 222 444 Skip Skip Cave Cave Consulting LLC On Mon, Oct 2, 2017 at 2:40 PM, Raul Millerwrote: > Perhaps this is closer to what you want? > > F=:1 :', u@> { (~. (u@#"0~ i.@>:)&.> #/.~) y' > f=: /F > > *f 2 2 5 7 > 1 7 5 35 2 14 10 70 4 28 20 140 > +f 2 2 5 7 > 0 7 5 12 2 9 7 14 4 11 9 16 > > I probably should just merge the two definitions together, but I think > this works? > > (Note that I have sort of assumed that the verb argument to f is an > associative verb. If you're doing something where that is not the > case... well... I guess I would need more specification.) > > Thanks, > > -- > Raul > > > On Mon, Oct 2, 2017 at 3:17 PM, Skip Cave wrote: > > Sorry about the wrong terminology. What i meant was: > > > > Given a vector of random integers (there may be duplicates), what is the > > most concise and or efficient way to > > generate a list of the numbers along with the sum of all combinations of > > the numbers in a single vector? How about the products of all > > combinations? > > > > Skip Cave > > Cave Consulting LLC > > > > On Mon, Oct 2, 2017 at 1:51 PM, Raul Miller > wrote: > > > >> Prime factors of an integer are not, in the general case, a set. And > >> you really should be careful to avoid specifying a set when what you > >> want is not a set. > >> > >> You might be interested in > >> https://rosettacode.org/wiki/Factors_of_an_integer#J ? > >> > >> That said, refinement is an important part of the specification > >> process, so - since it seems you were looking for something different > >> - maybe it's worth redoing the specification? > >> > >> Thanks, > >> > >> -- > >> Raul > >> > >> > >> On Mon, Oct 2, 2017 at 2:09 PM, Skip Cave > wrote: > >> > My original approach was even more naive than Marc's: > >> > > >> > NB. from Roger Hui's Combinations essay on the J website: > >> > https://goo.gl/WL4nXn > >> > > >> > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this > >> 'comb2' > >> > > >> > NB. I used this definition because I could cut & paste one line, and > not > >> > require an editor > >> > > >> > a =. 2 2 5 5 > >> > > >> > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > >> > > >> > 100 20 50 4 10 25 2 5 > >> > > >> > > >> > I like to sort it: > >> > > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c > 4){a > >> > > >> > 2 4 5 10 20 25 50 100 > >> > > >> > > >> > The final goal of this exercise was to find all the divisors of an > >> integer > >> > (not just the prime divisors). > >> > > >> > > >> > So you need to find the prime factors of the integer, for example 100: > >> > > >> > > >> > ]a =. q:100 > >> > > >> > 2 2 5 5 > >> > > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, > |:(1 c > >> 4){a > >> > > >> > 2 4 5 10 20 25 50 100 > >> > > >> > > >> > So these are all the divisors of 100. > >> > > >> > > >> > To use Raul's verb, it needs some mods. I can't do the unique until > the > >> > end, because prime factors of an integer are often duplicated. > >> > > >> > > >> > F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's verb minus > the > >> initial > >> > unique > >> > > >> > */F1 q:100 NB. we take the product > >> > > >> > 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100 > >> > > >> > ~.*/F1 q:100 NB. Now we take the unique > >> > > >> > 1 5 25 2 10 50 4 20 100 > >> > > >> > /:~~.*/F1 q:100 NB. Sort it to make it pretty > >> > > >> > 1 2 4 5 10 20 25 50 100 > >> > > >> > > >> > Didn't really need the 1, but Raul likes the empty combination. > >> > > >> > > >> > Now we put it all in one verb: > >> > > >> > > >> > F2=. /:~~.*/F1 q: > >> > > >> > F2 100 > >> > > >> > |length error: F2 > >> > > >> > | F2 100 > >> > > >> > F2=. /:~~.*/F1 q:] > >> > > >> > F2 100 > >> > > >> > |domain error: F2 > >> > > >> > | F2 100 > >> > > >> > > >> > So this is above my pay grade. I'll have to stick with my
Re: [Jprogramming] (no subject)
Perhaps this is closer to what you want? F=:1 :', u@> { (~. (u@#"0~ i.@>:)&.> #/.~) y' f=: /F *f 2 2 5 7 1 7 5 35 2 14 10 70 4 28 20 140 +f 2 2 5 7 0 7 5 12 2 9 7 14 4 11 9 16 I probably should just merge the two definitions together, but I think this works? (Note that I have sort of assumed that the verb argument to f is an associative verb. If you're doing something where that is not the case... well... I guess I would need more specification.) Thanks, -- Raul On Mon, Oct 2, 2017 at 3:17 PM, Skip Cavewrote: > Sorry about the wrong terminology. What i meant was: > > Given a vector of random integers (there may be duplicates), what is the > most concise and or efficient way to > generate a list of the numbers along with the sum of all combinations of > the numbers in a single vector? How about the products of all > combinations? > > Skip Cave > Cave Consulting LLC > > On Mon, Oct 2, 2017 at 1:51 PM, Raul Miller wrote: > >> Prime factors of an integer are not, in the general case, a set. And >> you really should be careful to avoid specifying a set when what you >> want is not a set. >> >> You might be interested in >> https://rosettacode.org/wiki/Factors_of_an_integer#J ? >> >> That said, refinement is an important part of the specification >> process, so - since it seems you were looking for something different >> - maybe it's worth redoing the specification? >> >> Thanks, >> >> -- >> Raul >> >> >> On Mon, Oct 2, 2017 at 2:09 PM, Skip Cave wrote: >> > My original approach was even more naive than Marc's: >> > >> > NB. from Roger Hui's Combinations essay on the J website: >> > https://goo.gl/WL4nXn >> > >> > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this >> 'comb2' >> > >> > NB. I used this definition because I could cut & paste one line, and not >> > require an editor >> > >> > a =. 2 2 5 5 >> > >> > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a >> > >> > 100 20 50 4 10 25 2 5 >> > >> > >> > I like to sort it: >> > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a >> > >> > 2 4 5 10 20 25 50 100 >> > >> > >> > The final goal of this exercise was to find all the divisors of an >> integer >> > (not just the prime divisors). >> > >> > >> > So you need to find the prime factors of the integer, for example 100: >> > >> > >> > ]a =. q:100 >> > >> > 2 2 5 5 >> > >> > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c >> 4){a >> > >> > 2 4 5 10 20 25 50 100 >> > >> > >> > So these are all the divisors of 100. >> > >> > >> > To use Raul's verb, it needs some mods. I can't do the unique until the >> > end, because prime factors of an integer are often duplicated. >> > >> > >> > F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's verb minus the >> initial >> > unique >> > >> > */F1 q:100 NB. we take the product >> > >> > 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100 >> > >> > ~.*/F1 q:100 NB. Now we take the unique >> > >> > 1 5 25 2 10 50 4 20 100 >> > >> > /:~~.*/F1 q:100 NB. Sort it to make it pretty >> > >> > 1 2 4 5 10 20 25 50 100 >> > >> > >> > Didn't really need the 1, but Raul likes the empty combination. >> > >> > >> > Now we put it all in one verb: >> > >> > >> > F2=. /:~~.*/F1 q: >> > >> > F2 100 >> > >> > |length error: F2 >> > >> > | F2 100 >> > >> > F2=. /:~~.*/F1 q:] >> > >> > F2 100 >> > >> > |domain error: F2 >> > >> > | F2 100 >> > >> > >> > So this is above my pay grade. I'll have to stick with my inline code: >> > >> > >> > /:~~.*/F1 q:110 >> > >> > 1 2 5 10 11 22 55 110 >> > >> > /:~~.*/F1 q:43 >> > >> > 1 43 >> > >> > /:~~.*/F1 q:45 >> > >> > 1 3 5 9 15 45 >> > >> > /:~~.*/F1 q:444 >> > >> > 1 2 3 4 6 12 37 74 111 148 222 444 >> > >> > >> > So I can find all the divisors of an integer. >> > >> > >> > Skip >> > >> > >> > >> > >> > >> > >> > Skip Cave >> > Cave Consulting LLC >> > >> > On Mon, Oct 2, 2017 at 12:15 PM, Marc Simpson wrote: >> > >> >> More naive than Raul's approach, first pass using the 'stats' lib: >> >> >> >> a=.2 5 7 >> >> require'stats' >> >> combv=: ] {~ (comb #@]) >> >> 3 combv a >> >> 2 5 7 >> >> 2 combv a >> >> 2 5 >> >> 2 7 >> >> 5 7 >> >> 1 combv a >> >> 2 >> >> 5 >> >> 7 >> >> combos=: (1 + i.@#) <@combv"0 1 ] >> >> combos a >> >> ┌─┬───┬─┐ >> >> │2│2 5│2 5 7│ >> >> │5│2 7│ │ >> >> │7│5 7│ │ >> >> └─┴───┴─┘ >> >> f=: 1 : ';u/"1 each combos y' >> >> +f a >> >> 2 5 7 7 9 12 14 >> >> *f a >> >> 2 5 7 10 14 35 70 >> >> >> >> /M >> >> >> >> On Mon, Oct 2, 2017 at 10:06 AM, Raul Miller >> >> wrote: >> >> > For a first effort, I would go with >> >> > >> >> > F=:1 :'(u@#~ #:@i.@(2^#))@~.' >> >> > f=: /F >> >> > >> >> > Hopefully that makes the issues obvious - the
Re: [Jprogramming] (no subject)
Sorry about the wrong terminology. What i meant was: Given a vector of random integers (there may be duplicates), what is the most concise and or efficient way to generate a list of the numbers along with the sum of all combinations of the numbers in a single vector? How about the products of all combinations? Skip Cave Cave Consulting LLC On Mon, Oct 2, 2017 at 1:51 PM, Raul Millerwrote: > Prime factors of an integer are not, in the general case, a set. And > you really should be careful to avoid specifying a set when what you > want is not a set. > > You might be interested in > https://rosettacode.org/wiki/Factors_of_an_integer#J ? > > That said, refinement is an important part of the specification > process, so - since it seems you were looking for something different > - maybe it's worth redoing the specification? > > Thanks, > > -- > Raul > > > On Mon, Oct 2, 2017 at 2:09 PM, Skip Cave wrote: > > My original approach was even more naive than Marc's: > > > > NB. from Roger Hui's Combinations essay on the J website: > > https://goo.gl/WL4nXn > > > > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this > 'comb2' > > > > NB. I used this definition because I could cut & paste one line, and not > > require an editor > > > > a =. 2 2 5 5 > > > > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > > > > 100 20 50 4 10 25 2 5 > > > > > > I like to sort it: > > > > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > > > > 2 4 5 10 20 25 50 100 > > > > > > The final goal of this exercise was to find all the divisors of an > integer > > (not just the prime divisors). > > > > > > So you need to find the prime factors of the integer, for example 100: > > > > > > ]a =. q:100 > > > > 2 2 5 5 > > > > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c > 4){a > > > > 2 4 5 10 20 25 50 100 > > > > > > So these are all the divisors of 100. > > > > > > To use Raul's verb, it needs some mods. I can't do the unique until the > > end, because prime factors of an integer are often duplicated. > > > > > > F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's verb minus the > initial > > unique > > > > */F1 q:100 NB. we take the product > > > > 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100 > > > > ~.*/F1 q:100 NB. Now we take the unique > > > > 1 5 25 2 10 50 4 20 100 > > > > /:~~.*/F1 q:100 NB. Sort it to make it pretty > > > > 1 2 4 5 10 20 25 50 100 > > > > > > Didn't really need the 1, but Raul likes the empty combination. > > > > > > Now we put it all in one verb: > > > > > > F2=. /:~~.*/F1 q: > > > > F2 100 > > > > |length error: F2 > > > > | F2 100 > > > > F2=. /:~~.*/F1 q:] > > > > F2 100 > > > > |domain error: F2 > > > > | F2 100 > > > > > > So this is above my pay grade. I'll have to stick with my inline code: > > > > > > /:~~.*/F1 q:110 > > > > 1 2 5 10 11 22 55 110 > > > > /:~~.*/F1 q:43 > > > > 1 43 > > > > /:~~.*/F1 q:45 > > > > 1 3 5 9 15 45 > > > > /:~~.*/F1 q:444 > > > > 1 2 3 4 6 12 37 74 111 148 222 444 > > > > > > So I can find all the divisors of an integer. > > > > > > Skip > > > > > > > > > > > > > > Skip Cave > > Cave Consulting LLC > > > > On Mon, Oct 2, 2017 at 12:15 PM, Marc Simpson wrote: > > > >> More naive than Raul's approach, first pass using the 'stats' lib: > >> > >> a=.2 5 7 > >> require'stats' > >> combv=: ] {~ (comb #@]) > >> 3 combv a > >> 2 5 7 > >> 2 combv a > >> 2 5 > >> 2 7 > >> 5 7 > >> 1 combv a > >> 2 > >> 5 > >> 7 > >> combos=: (1 + i.@#) <@combv"0 1 ] > >> combos a > >> ┌─┬───┬─┐ > >> │2│2 5│2 5 7│ > >> │5│2 7│ │ > >> │7│5 7│ │ > >> └─┴───┴─┘ > >> f=: 1 : ';u/"1 each combos y' > >> +f a > >> 2 5 7 7 9 12 14 > >> *f a > >> 2 5 7 10 14 35 70 > >> > >> /M > >> > >> On Mon, Oct 2, 2017 at 10:06 AM, Raul Miller > >> wrote: > >> > For a first effort, I would go with > >> > > >> > F=:1 :'(u@#~ #:@i.@(2^#))@~.' > >> > f=: /F > >> > > >> > Hopefully that makes the issues obvious - the specification here calls > >> > for a result which grows exponentially with the size of the argument > >> > set. > >> > > >> > Also: > >> > > >> > The ~. might be extra work, but for typical cases the effort of > >> > ensuring that the argument is a set is trivial compared to the effort > >> > of constructing the result. > >> > > >> > You did not include the empty combination in your example results, but > >> > given your specification my initial inclination is to treat that as an > >> > oversight. > >> > > >> > I defined F instead of going straight for f because for testing > >> > purposes I want to be able to do ( >> > > >> > Thanks, > >> > > >> > -- > >> > Raul > >> > > >> > > >> > On Mon, Oct 2, 2017 at 12:49 PM, Skip Cave > >> wrote: >
Re: [Jprogramming] (no subject)
Prime factors of an integer are not, in the general case, a set. And you really should be careful to avoid specifying a set when what you want is not a set. You might be interested in https://rosettacode.org/wiki/Factors_of_an_integer#J ? That said, refinement is an important part of the specification process, so - since it seems you were looking for something different - maybe it's worth redoing the specification? Thanks, -- Raul On Mon, Oct 2, 2017 at 2:09 PM, Skip Cavewrote: > My original approach was even more naive than Marc's: > > NB. fromRoger Hui's Combinations essay on the J website: > https://goo.gl/WL4nXn > > c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this 'comb2' > > NB. I used this definition because I could cut & paste one line, and not > require an editor > > a =. 2 2 5 5 > > ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > > 100 20 50 4 10 25 2 5 > > > I like to sort it: > > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > > 2 4 5 10 20 25 50 100 > > > The final goal of this exercise was to find all the divisors of an integer > (not just the prime divisors). > > > So you need to find the prime factors of the integer, for example 100: > > > ]a =. q:100 > > 2 2 5 5 > > /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a > > 2 4 5 10 20 25 50 100 > > > So these are all the divisors of 100. > > > To use Raul's verb, it needs some mods. I can't do the unique until the > end, because prime factors of an integer are often duplicated. > > > F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's verb minus the initial > unique > > */F1 q:100 NB. we take the product > > 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100 > > ~.*/F1 q:100 NB. Now we take the unique > > 1 5 25 2 10 50 4 20 100 > > /:~~.*/F1 q:100 NB. Sort it to make it pretty > > 1 2 4 5 10 20 25 50 100 > > > Didn't really need the 1, but Raul likes the empty combination. > > > Now we put it all in one verb: > > > F2=. /:~~.*/F1 q: > > F2 100 > > |length error: F2 > > | F2 100 > > F2=. /:~~.*/F1 q:] > > F2 100 > > |domain error: F2 > > | F2 100 > > > So this is above my pay grade. I'll have to stick with my inline code: > > > /:~~.*/F1 q:110 > > 1 2 5 10 11 22 55 110 > > /:~~.*/F1 q:43 > > 1 43 > > /:~~.*/F1 q:45 > > 1 3 5 9 15 45 > > /:~~.*/F1 q:444 > > 1 2 3 4 6 12 37 74 111 148 222 444 > > > So I can find all the divisors of an integer. > > > Skip > > > > > > > Skip Cave > Cave Consulting LLC > > On Mon, Oct 2, 2017 at 12:15 PM, Marc Simpson wrote: > >> More naive than Raul's approach, first pass using the 'stats' lib: >> >> a=.2 5 7 >> require'stats' >> combv=: ] {~ (comb #@]) >> 3 combv a >> 2 5 7 >> 2 combv a >> 2 5 >> 2 7 >> 5 7 >> 1 combv a >> 2 >> 5 >> 7 >> combos=: (1 + i.@#) <@combv"0 1 ] >> combos a >> ┌─┬───┬─┐ >> │2│2 5│2 5 7│ >> │5│2 7│ │ >> │7│5 7│ │ >> └─┴───┴─┘ >> f=: 1 : ';u/"1 each combos y' >> +f a >> 2 5 7 7 9 12 14 >> *f a >> 2 5 7 10 14 35 70 >> >> /M >> >> On Mon, Oct 2, 2017 at 10:06 AM, Raul Miller >> wrote: >> > For a first effort, I would go with >> > >> > F=:1 :'(u@#~ #:@i.@(2^#))@~.' >> > f=: /F >> > >> > Hopefully that makes the issues obvious - the specification here calls >> > for a result which grows exponentially with the size of the argument >> > set. >> > >> > Also: >> > >> > The ~. might be extra work, but for typical cases the effort of >> > ensuring that the argument is a set is trivial compared to the effort >> > of constructing the result. >> > >> > You did not include the empty combination in your example results, but >> > given your specification my initial inclination is to treat that as an >> > oversight. >> > >> > I defined F instead of going straight for f because for testing >> > purposes I want to be able to do (> > >> > Thanks, >> > >> > -- >> > Raul >> > >> > >> > On Mon, Oct 2, 2017 at 12:49 PM, Skip Cave >> wrote: >> >> Given a set of integers, what is the most concise and or efficient way >> to >> >> list the numbers along with the sum of all combinations of the numbers? >> the >> >> products of all combinations? >> >> >> >> for example: >> >> >> >> a =. 2 5 7 >> >> + f a NB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) >> >> 2 5 7 7 9 12 14 >> >> >> >> * f a NB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) >> >> 2 5 7 10 14 35 70 >> >> >> >> The function 'f' should work for any verb and any size right argument >> noun >> >> vector. >> >> >> >> Skip >> >> >> >> 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] zmq - big step for J socket services
I believe I once got wd to work in jconsole by building my own event-handler but don't think I have a working example to share. On Mon, Oct 2, 2017 at 12:11 AM, bill lamwrote: > jconsole and jhs can not run wd commands and I > don't think problem is qt related or can be solved > by qt. > > I had tried commenting the line in jcs_lab.ijs > 'must be < 20' assert y<20 > > also change 'e7' to 'e5' > > Then this sentence ran fine on linux64 jconsole > intel core i-7 quad-core (hyperthread disabled) > > (qrun bind 99 99)^:10 '' > > Пт, 29 сен 2017, jprogramming написал(а): > > > > A solid accidental fix comes from changing echo: > > > > > > echo_z_ =: (0 0 $1!:2&2)`(wd bind 'msgs' ] 0 0 $ 1!:2&2)@.IFQT > > > > the liberal amount of wd 'msgs' in qrun, seems to let the system > (perhaps down to zmq) catch up to the state it thinks it should be in. > > > > From: 'Pascal Jasmin' via Programming > > To: "programm...@jsoftware.com" > > Sent: Friday, September 29, 2017 3:50 PM > > Subject: Re: [Jprogramming] zmq - big step for J socket services > > > > > > > > > > > > changing the kill verb to: > > > > kill=: 3 : 0 > > access=: su > > runa'exit 0' > > killp PORT NB. new line. > > destroy'' > > i.0 0 > > ) > > > > > > helps with the sockets command consistently returning empty, and in > general lengthens the test lifetime but > > > > qrun 11 11 will still fail within 3 "reruns" > > > > (qrun modified to use e6 instead of e7 for convenience) > > > > windows 10 > > > > > > > > From: Eric Iverson > > To: Programming forum > > Sent: Friday, September 29, 2017 9:59 AM > > Subject: Re: [Jprogramming] zmq - big step for J socket services > > > > > > > > When you get a server error, lse__c gives you the J error message. I > think > > this is covered in the lab and in the help. > > > > kill and related things depend on host services and that code is still a > > bit rough and naive. It will be cleaned bup with experience or more > > rigorous study. Problems in this area are do not indicate zmq problems > per > > se. > > > > Tracking down qrun hang would be worthwhile. Again, I will bet it has to > do > > with starting/tracking/killing tasks and not directly a zmq problem. > > > > On Thu, Sep 28, 2017 at 7:14 PM, 'Pascal Jasmin' via Programming < > > programm...@jsoftware.com> wrote: > > > > > its working pretty well, > > > > > > A suggestion for generic "server error" would be to return the J error > > > from the J server instead. Useful for the examples you are showing > now. > > > (basically show lse__ as client response) > > > > > > > > > > > > The labs and examples do eventually hang if repeated enough though. > > > A repeated crash on the zmq lab occurs after the lines > > > > > > kill__c '' > > > kill__d '' > > > > > > servers_jcs_ '' still shows the c port open 65201 > > > > > > then "jcst port" hangs. > > > > > > killp_jcs_ 65201 removes it from servers > > > the kill__c command later in the lab does not crash. > > > > > > > > > if qrun is repeated enough times, it will also hang the j session. > > > > > > From: Eric Iverson > > > To: Programming forum > > > Sent: Thursday, September 28, 2017 1:04 PM > > > Subject: [Jprogramming] zmq - big step for J socket services > > > > > > > > > > > > New addons net/zmq and net/jcs are available. They require 806. > > > > > > > > > The zmq addon has bindings between J and the zmq shared library. > > > > > > > > > The jcs addon has J client/server tools built on the zmq request/reply > > > > > > pattern. > > > > > > > > > These addons make it much easier and with far less code to provide > > > > > > high-performance, robust, and scalable socket services. > > > > > > > > > Start with 806-beta-6 installed from the latest zip packages. Then be > sure > > > > > > you have the > > > > > > latest base library and the net/zmq and net/jcs addons installed. > > > > > > > > > An easy way to get started is to run the jcs lab. > > > > > > > > > start J > > > > > >load'labs/labs' > > > > > >lab'~addons/net/jcs/jcs_lab.ijs' > > > > > > step through the lab > > > > > > > > > The lab will let you know if you need to install zmq and where to look > for > > > > > > info. > > > > > > > > > Sharing zmq install hints in the forum could save others some trouble. > > > > > > > > > *** > > > > > > Among other things, jcs makes it easy to start other J tasks and to use > > > > > > them as servers. The lab includes a simple example of starting > multiple J > > > > > > tasks to service a queue of jobs. > > > > > > > > > *** from the jcs lab > > > > > > zmq is an api built on top of sockets > > > > > > > > > it is available across platforms and removes almost all the mundane and > > > > > > critical chores in
Re: [Jprogramming] Composition conjunctions
On Mon, Oct 2, 2017 at 11:13 AM, Erling Hellenäswrote: > And what would you call these posts. A factual discussion? /Erling Sure; a discussion with suggestions, differing opinions. I find dismissing replies as 'spam' a tad rude; let's try and keep conversation civil and friendly (on all sides)? Anyway, I've said my piece; don't want to derail this thread further. Best, M -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
And what would you call these posts. A factual discussion? /Erling On 2017-10-02 19:54, Marc Simpson wrote: On Mon, Oct 2, 2017 at 10:51 AM, Erling Hellenäswrote: [snip] Normally, if I get spammed like this, I would assume that what I said WAS important, and I'd repost it and write more about it. Referring to on-list replies as 'spam' is rather insulting to those who take time to respond. -- 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] (no subject)
My original approach was even more naive than Marc's: NB. fromRoger Hui's Combinations essay on the J website: https://goo.gl/WL4nXn c=: ((= +/"1) |.@:I.@# ]) #:@i.@(2&^) NB. Roger called this 'comb2' NB. I used this definition because I could cut & paste one line, and not require an editor a =. 2 2 5 5 ~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a 100 20 50 4 10 25 2 5 I like to sort it: /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a 2 4 5 10 20 25 50 100 The final goal of this exercise was to find all the divisors of an integer (not just the prime divisors). So you need to find the prime factors of the integer, for example 100: ]a =. q:100 2 2 5 5 /:~~.(*/"1(4 c 4){a),(*/"1(3 c 4){a),(*/"1(2 c 4){a),, |:(1 c 4){a 2 4 5 10 20 25 50 100 So these are all the divisors of 100. To use Raul's verb, it needs some mods. I can't do the unique until the end, because prime factors of an integer are often duplicated. F1=:1 :'u@#~ #:@i.@(2^#)' NB. Here's Raul's verb minus the initial unique */F1 q:100 NB. we take the product 1 5 5 25 2 10 10 50 2 10 10 50 4 20 20 100 ~.*/F1 q:100 NB. Now we take the unique 1 5 25 2 10 50 4 20 100 /:~~.*/F1 q:100 NB. Sort it to make it pretty 1 2 4 5 10 20 25 50 100 Didn't really need the 1, but Raul likes the empty combination. Now we put it all in one verb: F2=. /:~~.*/F1 q: F2 100 |length error: F2 | F2 100 F2=. /:~~.*/F1 q:] F2 100 |domain error: F2 | F2 100 So this is above my pay grade. I'll have to stick with my inline code: /:~~.*/F1 q:110 1 2 5 10 11 22 55 110 /:~~.*/F1 q:43 1 43 /:~~.*/F1 q:45 1 3 5 9 15 45 /:~~.*/F1 q:444 1 2 3 4 6 12 37 74 111 148 222 444 So I can find all the divisors of an integer. Skip Skip Cave Cave Consulting LLC On Mon, Oct 2, 2017 at 12:15 PM, Marc Simpsonwrote: > More naive than Raul's approach, first pass using the 'stats' lib: > > a=.2 5 7 > require'stats' > combv=: ] {~ (comb #@]) > 3 combv a > 2 5 7 > 2 combv a > 2 5 > 2 7 > 5 7 > 1 combv a > 2 > 5 > 7 > combos=: (1 + i.@#) <@combv"0 1 ] > combos a > ┌─┬───┬─┐ > │2│2 5│2 5 7│ > │5│2 7│ │ > │7│5 7│ │ > └─┴───┴─┘ > f=: 1 : ';u/"1 each combos y' > +f a > 2 5 7 7 9 12 14 > *f a > 2 5 7 10 14 35 70 > > /M > > On Mon, Oct 2, 2017 at 10:06 AM, Raul Miller > wrote: > > For a first effort, I would go with > > > > F=:1 :'(u@#~ #:@i.@(2^#))@~.' > > f=: /F > > > > Hopefully that makes the issues obvious - the specification here calls > > for a result which grows exponentially with the size of the argument > > set. > > > > Also: > > > > The ~. might be extra work, but for typical cases the effort of > > ensuring that the argument is a set is trivial compared to the effort > > of constructing the result. > > > > You did not include the empty combination in your example results, but > > given your specification my initial inclination is to treat that as an > > oversight. > > > > I defined F instead of going straight for f because for testing > > purposes I want to be able to do ( > > > Thanks, > > > > -- > > Raul > > > > > > On Mon, Oct 2, 2017 at 12:49 PM, Skip Cave > wrote: > >> Given a set of integers, what is the most concise and or efficient way > to > >> list the numbers along with the sum of all combinations of the numbers? > the > >> products of all combinations? > >> > >> for example: > >> > >> a =. 2 5 7 > >> + f a NB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) > >> 2 5 7 7 9 12 14 > >> > >> * f a NB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) > >> 2 5 7 10 14 35 70 > >> > >> The function 'f' should work for any verb and any size right argument > noun > >> vector. > >> > >> Skip > >> > >> 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 > -- > 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] Composition conjunctions
Beyond wether these tests are useful or not, you should run "ts" with a left argument, as a single run which lasts only 0.1 seconds can be somewhat imprecise. ts's left argument n is the number of times to run the string of code, and its result will be the total time elapsed divided by n. Cheers, Louis > On 2 Oct 2017, at 19:51, Erling Hellenäswrote: > > Hi all! > > If something is not interesting or important, a good general idea could be to > not spend forum time on lengthy discussions about it? > Normally, if I get spammed like this, I would assume that what I said WAS > important, and I'd repost it and write more about it. However, since this is > a proprietary mail list I will have to leave that to the readers. > > Cheers, > Erling >> On 2017-10-02 19:26, Don Guinn wrote: >> Detailed measurements are useful and meaningful if your application is >> performing badly. But general statements about poor performance in parts of >> an application that isn't used much is a waste of time. >> >> @ vs. @: is a concern but blanket proclamations is wrong. Today @ performs >> better than @: most of the time, especially for primitives. But for defined >> verbs, depending on the design, there may be no performance gain and a lot >> of wasted memory. >> >> If you have an app with a performance problem then run a tool to find out >> where you're spending the time. J has such a tool, as do almost all >> programming languages. Now you know where to spend your time. >> >> And you may find out that the problem is not in J, but in your design. >> >> There is no argument that @ has much room for improvement. Which seems to >> be what your beef is about. So you're wasting your time and everybody >> else's time proving the obvious. >> >>> On Oct 2, 2017 10:06 AM, "Erling Hellenäs" wrote: >>> >>> You are welcome to show us better measurements if you think these >>> measurements are very important and worthy of a lengthy discussion in the >>> forum. /Erling >>> On 2017-10-02 17:53, Raul Miller wrote: The null case here should be ] (-@- -: ]) v 1 Thanks, >>> -- >>> 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] Composition conjunctions
On Mon, Oct 2, 2017 at 10:51 AM, Erling Hellenäswrote: > [snip] > Normally, if I get spammed like this, I would assume that what I said WAS > important, and I'd repost it and write more about it. Referring to on-list replies as 'spam' is rather insulting to those who take time to respond. -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
Hi all! If something is not interesting or important, a good general idea could be to not spend forum time on lengthy discussions about it? Normally, if I get spammed like this, I would assume that what I said WAS important, and I'd repost it and write more about it. However, since this is a proprietary mail list I will have to leave that to the readers. Cheers, Erling On 2017-10-02 19:26, Don Guinn wrote: Detailed measurements are useful and meaningful if your application is performing badly. But general statements about poor performance in parts of an application that isn't used much is a waste of time. @ vs. @: is a concern but blanket proclamations is wrong. Today @ performs better than @: most of the time, especially for primitives. But for defined verbs, depending on the design, there may be no performance gain and a lot of wasted memory. If you have an app with a performance problem then run a tool to find out where you're spending the time. J has such a tool, as do almost all programming languages. Now you know where to spend your time. And you may find out that the problem is not in J, but in your design. There is no argument that @ has much room for improvement. Which seems to be what your beef is about. So you're wasting your time and everybody else's time proving the obvious. On Oct 2, 2017 10:06 AM, "Erling Hellenäs"wrote: You are welcome to show us better measurements if you think these measurements are very important and worthy of a lengthy discussion in the forum. /Erling On 2017-10-02 17:53, Raul Miller wrote: The null case here should be ] (-@- -: ]) v 1 Thanks, -- 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] (no subject)
Hi all! You don't want the combination of zero elements? a=: 2 5 7 /:~(#: i. 2 ^ # a) ([:+/#) /"1 1 a 0 2 5 7 7 9 12 14 /:~(#: i. 2 ^ # a) ([:*/#) /"1 1 a 1 2 5 7 10 14 35 70 Guess I could drop it. Cheers, Erling On 2017-10-02 18:49, Skip Cave wrote: Given a set of integers, what is the most concise and or efficient way to list the numbers along with the sum of all combinations of the numbers? the products of all combinations? for example: a =. 2 5 7 + f aNB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) 2 5 7 7 9 12 14 * f aNB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) 2 5 7 10 14 35 70 The function 'f' should work for any verb and any size right argument noun vector. Skip 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] (no subject)
http://code.jsoftware.com/wiki/Essays/Power_Set is an essay by Roger Hui about power sets, including a number of ways to generate these, such as: ps0 =: #:@i.@(2&^)@# <@#"1 _ ] ps0 2 5 7 ┌┬─┬─┬───┬─┬───┬───┬─┐ ││7│5│5 7│2│2 7│2 5│2 5 7│ └┴─┴─┴───┴─┴───┴───┴─┘ Now your f can be: f =: 1 : '}. /:~ ; u/ each ps0 y' + f 2 5 7 2 5 7 7 9 12 14 * f 2 5 7 2 5 7 10 14 35 70 Ben From: Programming [programming-boun...@forums.jsoftware.com] on behalf of Skip Cave [s...@caveconsulting.com] Sent: Monday, October 02, 2017 18:49 To: programm...@jsoftware.com Subject: [Jprogramming] (no subject) Given a set of integers, what is the most concise and or efficient way to list the numbers along with the sum of all combinations of the numbers? the products of all combinations? for example: a =. 2 5 7 + f aNB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) 2 5 7 7 9 12 14 * f aNB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) 2 5 7 10 14 35 70 The function 'f' should work for any verb and any size right argument noun vector. Skip 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] Composition conjunctions
Well... hypothetically speaking, a case might be made for special code which evaluates -@- with a domain check and then ] -- but I guess we are not seeing anything useful about that case yet. And there's a small cost to special code, so we usually don't want it doing things people should not use. Thanks, -- Raul On Mon, Oct 2, 2017 at 1:26 PM, Don Guinnwrote: > Detailed measurements are useful and meaningful if your application is > performing badly. But general statements about poor performance in parts of > an application that isn't used much is a waste of time. > > @ vs. @: is a concern but blanket proclamations is wrong. Today @ performs > better than @: most of the time, especially for primitives. But for defined > verbs, depending on the design, there may be no performance gain and a lot > of wasted memory. > > If you have an app with a performance problem then run a tool to find out > where you're spending the time. J has such a tool, as do almost all > programming languages. Now you know where to spend your time. > > And you may find out that the problem is not in J, but in your design. > > There is no argument that @ has much room for improvement. Which seems to > be what your beef is about. So you're wasting your time and everybody > else's time proving the obvious. > > On Oct 2, 2017 10:06 AM, "Erling Hellenäs" wrote: > >> You are welcome to show us better measurements if you think these >> measurements are very important and worthy of a lengthy discussion in the >> forum. /Erling >> >> On 2017-10-02 17:53, Raul Miller wrote: >> >>> The null case here should be ] >>> >>> (-@- -: ]) v >>> 1 >>> >>> Thanks, >>> >>> >> -- >> 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] advancing in labs in jconsole
In j806 console, to advance enter: lab 0 On Mon, Oct 2, 2017 at 10:18 AM, 'Pascal Jasmin' via Programming < programm...@jsoftware.com> wrote: > How would I advance to next section in a lab with jconsole 8.06 (windows > 10)? > > | | Virus-free. www.avast.com | > > -- > 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] Composition conjunctions
Detailed measurements are useful and meaningful if your application is performing badly. But general statements about poor performance in parts of an application that isn't used much is a waste of time. @ vs. @: is a concern but blanket proclamations is wrong. Today @ performs better than @: most of the time, especially for primitives. But for defined verbs, depending on the design, there may be no performance gain and a lot of wasted memory. If you have an app with a performance problem then run a tool to find out where you're spending the time. J has such a tool, as do almost all programming languages. Now you know where to spend your time. And you may find out that the problem is not in J, but in your design. There is no argument that @ has much room for improvement. Which seems to be what your beef is about. So you're wasting your time and everybody else's time proving the obvious. On Oct 2, 2017 10:06 AM, "Erling Hellenäs"wrote: > You are welcome to show us better measurements if you think these > measurements are very important and worthy of a lengthy discussion in the > forum. /Erling > > On 2017-10-02 17:53, Raul Miller wrote: > >> The null case here should be ] >> >> (-@- -: ]) v >> 1 >> >> Thanks, >> >> > -- > 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] advancing in labs in jconsole
How would I advance to next section in a lab with jconsole 8.06 (windows 10)? | | Virus-free. www.avast.com | -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] (no subject)
More naive than Raul's approach, first pass using the 'stats' lib: a=.2 5 7 require'stats' combv=: ] {~ (comb #@]) 3 combv a 2 5 7 2 combv a 2 5 2 7 5 7 1 combv a 2 5 7 combos=: (1 + i.@#) <@combv"0 1 ] combos a ┌─┬───┬─┐ │2│2 5│2 5 7│ │5│2 7│ │ │7│5 7│ │ └─┴───┴─┘ f=: 1 : ';u/"1 each combos y' +f a 2 5 7 7 9 12 14 *f a 2 5 7 10 14 35 70 /M On Mon, Oct 2, 2017 at 10:06 AM, Raul Millerwrote: > For a first effort, I would go with > > F=:1 :'(u@#~ #:@i.@(2^#))@~.' > f=: /F > > Hopefully that makes the issues obvious - the specification here calls > for a result which grows exponentially with the size of the argument > set. > > Also: > > The ~. might be extra work, but for typical cases the effort of > ensuring that the argument is a set is trivial compared to the effort > of constructing the result. > > You did not include the empty combination in your example results, but > given your specification my initial inclination is to treat that as an > oversight. > > I defined F instead of going straight for f because for testing > purposes I want to be able to do ( > Thanks, > > -- > Raul > > > On Mon, Oct 2, 2017 at 12:49 PM, Skip Cave wrote: >> Given a set of integers, what is the most concise and or efficient way to >> list the numbers along with the sum of all combinations of the numbers? the >> products of all combinations? >> >> for example: >> >> a =. 2 5 7 >> + f aNB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) >> 2 5 7 7 9 12 14 >> >> * f aNB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) >> 2 5 7 10 14 35 70 >> >> The function 'f' should work for any verb and any size right argument noun >> vector. >> >> Skip >> >> 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 -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] (no subject)
For a first effort, I would go with F=:1 :'(u@#~ #:@i.@(2^#))@~.' f=: /F Hopefully that makes the issues obvious - the specification here calls for a result which grows exponentially with the size of the argument set. Also: The ~. might be extra work, but for typical cases the effort of ensuring that the argument is a set is trivial compared to the effort of constructing the result. You did not include the empty combination in your example results, but given your specification my initial inclination is to treat that as an oversight. I defined F instead of going straight for f because for testing purposes I want to be able to do ( wrote: > Given a set of integers, what is the most concise and or efficient way to > list the numbers along with the sum of all combinations of the numbers? the > products of all combinations? > > for example: > > a =. 2 5 7 > + f aNB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) > 2 5 7 7 9 12 14 > > * f aNB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) > 2 5 7 10 14 35 70 > > The function 'f' should work for any verb and any size right argument noun > vector. > > Skip > > 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
[Jprogramming] (no subject)
Given a set of integers, what is the most concise and or efficient way to list the numbers along with the sum of all combinations of the numbers? the products of all combinations? for example: a =. 2 5 7 + f aNB. 2, 5, 7, (2+5), (2+7), (5+7), (2+5+7) 2 5 7 7 9 12 14 * f aNB. 2, 5, 7, (2*5), (2*7), (5*7), (2*5*7) 2 5 7 10 14 35 70 The function 'f' should work for any verb and any size right argument noun vector. Skip Skip Cave Cave Consulting LLC -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
I actually don't think these particular measurements are all that relevant. And I guess I should apologize for not making that clear. That said, I think timing the test suite which comes with j source (except for the *t.* files -- too many race conditions there) is kind of interesting. Thanks, -- Raul On Mon, Oct 2, 2017 at 12:06 PM, Erling Hellenäswrote: > You are welcome to show us better measurements if you think these > measurements are very important and worthy of a lengthy discussion in the > forum. /Erling > > On 2017-10-02 17:53, Raul Miller wrote: >> >> The null case here should be ] >> >> (-@- -: ]) v >> 1 >> >> Thanks, >> > > -- > 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] Composition conjunctions
You are welcome to show us better measurements if you think these measurements are very important and worthy of a lengthy discussion in the forum. /Erling On 2017-10-02 17:53, Raul Miller wrote: The null case here should be ] (-@- -: ]) v 1 Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
Hi all ! Here are the same measurements with Bill Lams proposed way to measure this. As we can all see it is lousy because the overhead in the measurement loop is much higher than that in @. n=.50 v=.?~n $v 50 10{.v 414253 208033 396027 190208 112248 196018 51503 465441 277514 114236 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.258554 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.260208 1.322e8 ts'-At-At-At-At-Atop- v' 2.98929 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.154225 1.32197e8 ts'-@- v' 0.0907723 1.32195e8 v=.1 n*{.n ts'-@:-@:-@:-@:- v' 0.455432 Cheers, Erling On 2017-10-02 17:24, Raul Miller wrote: Believe me, I understood that. But this particular performance measure is rather like measuring the performance of tires sliding sideways (as opposed to rolling) in a parking lot while carrying several hundred pounds of meatloaf. In other words, it's not something I would feel comfortable optimizing for, though I can sort of almost see some sort of vague connection to real applications if I do not think about it too much. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
The null case here should be ] (-@- -: ]) v 1 Thanks, -- Raul On Mon, Oct 2, 2017 at 11:48 AM, Erling Hellenäswrote: > Hi all ! > > Here are the same measurements with a null case we can deduct, if we want to > know the exact speed on my particular machine. > >ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' > 0.261088 1.32199e8 >ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' > 0.264798 1.322e8 >ts'-At-At-At-At-Atop- v' > 2.97941 1.32204e8 >ts'-@:-@:-@:-@:-@- v' > 0.156113 1.32197e8 >ts'-@- v' > 0.091478 1.32195e8 > > Cheers, > Erling > > On 2017-10-02 17:24, Raul Miller wrote: >> >> Believe me, I understood that. >> >> But this particular performance measure is rather like measuring the >> performance of tires sliding sideways (as opposed to rolling) in a >> parking lot while carrying several hundred pounds of meatloaf. >> >> In other words, it's not something I would feel comfortable optimizing >> for, though I can sort of almost see some sort of vague connection to >> real applications if I do not think about it too much. >> >> Thanks, >> > > -- > 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] Composition conjunctions
Hi all ! Here are the same measurements with a null case we can deduct, if we want to know the exact speed on my particular machine. ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.261088 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.264798 1.322e8 ts'-At-At-At-At-Atop- v' 2.97941 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.156113 1.32197e8 ts'-@- v' 0.091478 1.32195e8 Cheers, Erling On 2017-10-02 17:24, Raul Miller wrote: Believe me, I understood that. But this particular performance measure is rather like measuring the performance of tires sliding sideways (as opposed to rolling) in a parking lot while carrying several hundred pounds of meatloaf. In other words, it's not something I would feel comfortable optimizing for, though I can sort of almost see some sort of vague connection to real applications if I do not think about it too much. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
Well, I do some observations and if anyone finds them interesting he can respond. Anyone can do their own measurement. It does not obviously improve the discussion to look for all kinds of perceived faults in peoples posts and start discussion these, instead of the subject of the thread? /Erling On 2017-10-02 17:24, Raul Miller wrote: Believe me, I understood that. But this particular performance measure is rather like measuring the performance of tires sliding sideways (as opposed to rolling) in a parking lot while carrying several hundred pounds of meatloaf. In other words, it's not something I would feel comfortable optimizing for, though I can sort of almost see some sort of vague connection to real applications if I do not think about it too much. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
Yes, I was not sure if it might only concern the Unix binaries, but since it worked on my machine it seemed to concern the Windows binaries too. Thanks for clearing it out. /Erling On 2017-10-02 17:26, Jose Mario Quintana wrote: " I guess the Jx j.dll is compiled without it." That is correct, both, the provided dll and the so binaries do not support avx as stated in the release post: " Jx 1.1 Release A Jx v1.1 Extensions Guide, a J/Jx Cheatsheet, a Jx Assertions script together with links to a Windows 64 bit dll, a Unix 64 bit so binaries (without avx support) and the patch corresponding to the J806 source (beta-6) can be found at the link [0]. " On Mon, Oct 2, 2017 at 10:11 AM, Erling Hellenäswrote: Hi all ! These measurements are with Jx j.dll on the latest Beta release. n=.50 v=.?~n $v 50 10{.v 50689 85238 136693 442735 25192 304048 139323 96663 216893 142946 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.1156 4.19917e6 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.108927 4.20006e6 ts'-At-At-At-At-Atop- v' 3.30635 4.20416e6 ts'-@:-@:-@:-@:-@- v' 0.115168 4.19712e6 For some reason my tacit code is on par with the built in code here. The performance of my tacit code is doubled!!! in this release compared to latest stable. There is no avx on this machine. I guess the Jx j.dll is compiled without it. The explicit code is even slower here. The measurements from the latest stable, taken from below: n=.50 v=.?~n $v 50 10{.v 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.240852 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.2369 1.322e8 ts'-At-At-At-At-Atop- v' 2.96161 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.158078 1.32197e8 Cheers, Erling On 2017-10-02 15:42, Erling Hellenäs wrote: Hi all ! I tried to create explicit and tacit definitions of our composition conjunctions. I think the result could possibly be used to clarify the descriptions in NuVoc. Opinions are welcome, there are probably still some bugs or misunderstandings of function, there could be interesting aspects to discuss. The printout follows, then my project with definitions, tests and some minor explanations. In the end of the printout there are some performance measurements. The explicit versions are doing bad in those. The built in versions are slightly faster, which could be expected. Cheers, Erling Printout=== ts=: 6!:2 , 7!:2@] NB. Time and space At=: 2 : 0 NB. @: u v"_ y : u x v"_ y ) 1 2;3 4 ┌─┐ │_1 _2│ │_3 _4│ └─┘ NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfinite> 1 2;3 4 ┌───┐ │4 3│ │3 2│ └───┘ NB. < 2 2 $ 4 3 3 2 NB. &.: UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' -UnderRankInfiniteTacitMonadic> 1 2;3 4 ┌─┐ │_1 _2│ │_3 _4│ └─┘ NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 ┌───┐ │4 3│ │3 2│ └───┘ NB. < 2 2 $ 4 3 3 2 NB. &.: -UnderRankInfiniteTacitMonadic> [: >^:_1 [: - [: > ] -UnderRankInfiniteTacitDyadic> [: >^:_1 ([: > [) - [: > ] UnderRankV=: 2 : 0 NB. &. u UnderRankInfinite v"v y : x u UnderRankInfinite v"v y ) -UnderRankV> 1 2; 3 4 ┌─┬─┐ │_1 _2│_3 _4│ └─┴─┘ NB. _1 _2; _3 _4 (5;6) -UnderRankV> 1 2;3 4 ┌───┬───┐ │4 3│3 2│ └───┴───┘ NB. 4 3;3 2 NB. &. UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v' UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v' -UnderRankVTacitMonadic> 1 2; 3 4 ┌─┬─┐ │_1 _2│_3 _4│ └─┴─┘ NB. _1 _2; _3 _4 (5;6) -UnderRankVTacitDyadic> 1 2;3 4 ┌───┬───┐ │4 3│3 2│ └───┴───┘ NB. 4 3;3 2 NB. &. -UnderRankVTacitMonadic> ([: >^:_1 [: - [: > ])"0 0 0 -UnderRankVTacitDyadic> ([: >^:_1 ([: > [) - [: > ])"0 0 0 n=.50 v=.?~n $v 50 10{.v 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.240852 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.2369 1.322e8 ts'-At-At-At-At-Atop- v' 2.96161 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.158078 1.32197e8 == Project === ts=: 6!:2 , 7!:2@] NB. Time and space At=: 2 : 0 NB. @: u v"_ y : u x v"_ y ) 1 2;3 4 NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfinite> 1 2;3 4 NB. < 2 2 $ 4 3 3 2 NB. &.: UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' -UnderRankInfiniteTacitMonadic> 1 2;3 4 NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 NB. < 2 2 $ 4 3 3 2 NB. &.: -UnderRankInfiniteTacitMonadic> -UnderRankInfiniteTacitDyadic> UnderRankV=: 2 : 0 NB. &. u UnderRankInfinite v"v y : x u
Re: [Jprogramming] Composition conjunctions
" I guess the Jx j.dll is compiled without it." That is correct, both, the provided dll and the so binaries do not support avx as stated in the release post: " Jx 1.1 Release A Jx v1.1 Extensions Guide, a J/Jx Cheatsheet, a Jx Assertions script together with links to a Windows 64 bit dll, a Unix 64 bit so binaries (without avx support) and the patch corresponding to the J806 source (beta-6) can be found at the link [0]. " On Mon, Oct 2, 2017 at 10:11 AM, Erling Hellenäswrote: > Hi all ! > > These measurements are with Jx j.dll on the latest Beta release. > >n=.50 >v=.?~n >$v > 50 >10{.v > 50689 85238 136693 442735 25192 304048 139323 96663 216893 142946 >ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' > 0.1156 4.19917e6 >ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' > 0.108927 4.20006e6 >ts'-At-At-At-At-Atop- v' > 3.30635 4.20416e6 >ts'-@:-@:-@:-@:-@- v' > 0.115168 4.19712e6 > > For some reason my tacit code is on par with the built in code here. The > performance of my tacit code is doubled!!! in this release compared to > latest stable. There is no avx on this machine. I guess the Jx j.dll is > compiled without it. The explicit code is even slower here. > > The measurements from the latest stable, taken from below: > >n=.50 >v=.?~n >$v > 50 >10{.v > 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 >ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' > 0.240852 1.32199e8 >ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' > 0.2369 1.322e8 >ts'-At-At-At-At-Atop- v' > 2.96161 1.32204e8 >ts'-@:-@:-@:-@:-@- v' > 0.158078 1.32197e8 > > Cheers, > > Erling > > > On 2017-10-02 15:42, Erling Hellenäs wrote: > >> Hi all ! >> >> I tried to create explicit and tacit definitions of our composition >> conjunctions. I think the result could possibly be used to clarify the >> descriptions in NuVoc. >> >> Opinions are welcome, there are probably still some bugs or >> misunderstandings of function, there could be interesting aspects to >> discuss. >> >> The printout follows, then my project with definitions, tests and some >> minor explanations. >> >> In the end of the printout there are some performance measurements. The >> explicit versions are doing bad in those. The built in versions are >> slightly faster, which could be expected. >> >> Cheers, >> >> Erling >> >> Printout=== >> >>ts=: 6!:2 , 7!:2@] NB. Time and space >> >>At=: 2 : 0 >> NB. @: >> u v"_ y >> : >> u x v"_ y >> ) >> >>> ┌─┐ >> │_1 _2│ >> └─┘ >>NB. < _1_2 >>5 > ┌───┐ >> │4 3│ >> └───┘ >>NB. < 4 3 >> >>NB. @: >>AtTacit=: 2 : '[: u v' >> >> >>> ┌─┐ >> │_1 _2│ >> └─┘ >>NB. < _1_2 >>5 > ┌───┐ >> │4 3│ >> └───┘ >>NB. < 4 3 >> >>NB. @: >>> [: < - >> >>Atop=: 2 : 0 >> NB. @ >> u At v"v y >> : >> x u At v"v y >> ) >> >>> ┌──┬──┐ >> │_1│_2│ >> └──┴──┘ >>NB. _1;_2 >>5 > ┌─┬─┐ >> │4│3│ >> └─┴─┘ >>NB. 4;3 >> >>NB. @ >>AtopTacit=: 2 : '([: u v)"v' >> >>> ┌──┬──┐ >> │_1│_2│ >> └──┴──┘ >>NB. _1;_2 >>5 > ┌─┬─┐ >> │4│3│ >> └─┴─┘ >>NB. 4;3 >> >>NB. @ >>> ([: < -)"0 0 0 >> > ([: < [)"_ _ _ >>> ([: < i.)"1 _ _ >> >>Appose=: 2 : 0 >> NB. &: >> u v"_ y >> : >> (v"_ x) u v"_ y >> ) >> >>> ┌─┐ >> │_1 _2│ >> └─┘ >>NB. < _1 _2 >>5 ([:<<)Appose- 4 5 >> ┌───┐ >> │1 0│ >> └───┘ >>NB. < 1 0 >> >>NB. &: >>ApposeTacitMonadic=: 2 : '[: u [: v ]' >>ApposeTacitDyadic=: 2 : '([: v [) u [: v ]' >> >>> ┌─┐ >> │_1 _2│ >> └─┘ >>NB. < _1 _2 >>5 ([:<<)ApposeTacitDyadic- 4 5 >> ┌───┐ >> │1 0│ >> └───┘ >>NB. < 1 0 >> >>NB. &: >>> [: < [: - ] >>([:<<)ApposeTacitDyadic- >> ([: - [) ([: < <) [: - ] >> >>Compose=: 2 : 0 >> NB. & >> u Appose v"v y >> : >> x u Appose v"v y >> ) >> >>> ┌──┬──┐ >> │_1│_2│ >> └──┴──┘ >>NB. _1;_2 >>5 ([:<<)Compose- 4 5 >> ┌─┬─┐ >> │1│0│ >> └─┴─┘ >>NB. 1;0 >> >>NB. & >>ComposeTacitMonadic=: 2 : '([: u [: v ])"v' >>ComposeTacitDyadic=: 2 : '(([: v [) u [: v ])"v' >> >>> ┌──┬──┐ >> │_1│_2│ >> └──┴──┘ >>NB. _1;_2 >>5 ([:<<)ComposeTacitDyadic- 4 5 >> ┌─┬─┐ >> │1│0│ >> └─┴─┘ >>NB. 1;0 >> >>NB. & >>> ([: < [: - ])"0 0 0 >>([:<<)ComposeTacitDyadic- >> (([: - [) ([: < <) [: - ])"0 0 0 >> >>UnderRankInfinite=: 2 : 0 >> NB. &.: >> v"_^:_1 u v"_ y >> : >> v"_^:_1 (v"_ x) u v"_ y >> ) >> >>-UnderRankInfinite> 1 2;3 4 >> ┌─┐ >> │_1 _2│ >> │_3 _4│ >> └─┘ >>NB. <2 2 $ _1 _2 -3 -4 >>(5;6) -UnderRankInfinite> 1 2;3 4 >> ┌───┐ >> │4 3│ >> │3 2│ >> └───┘ >>NB. < 2 2 $ 4 3 3 2 >> >>NB. &.: >>UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' >>UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' >> >>-UnderRankInfiniteTacitMonadic> 1 2;3 4 >> ┌─┐ >> │_1 _2│ >> │_3 _4│ >> └─┘ >>NB. <2 2 $ _1 _2 -3
Re: [Jprogramming] Composition conjunctions
Believe me, I understood that. But this particular performance measure is rather like measuring the performance of tires sliding sideways (as opposed to rolling) in a parking lot while carrying several hundred pounds of meatloaf. In other words, it's not something I would feel comfortable optimizing for, though I can sort of almost see some sort of vague connection to real applications if I do not think about it too much. Thanks, -- Raul On Mon, Oct 2, 2017 at 11:12 AM, Erling Hellenäswrote: > Even if Raul wouldn't consider them meaningful for some reason I don't > understand it seems he should still understand that they are performance > measurements? That I am creating a loop over a piece of code to measure the > performance of this piece of code? /Erling > > > On 2017-10-02 17:01, Don Guinn wrote: >> >> How many times do you have to be told that these kinds of measurements and >> meaningless? >> >> On Oct 2, 2017 8:57 AM, "Erling Hellenäs" >> wrote: >> >>> How many times do I have to tell that I do this to measure performance? >>> /Erling >>> >>> On 2017-10-02 16:39, Raul Miller wrote: >>> Generally speaking, you want to push the large arrays into J's primitives as much as possible. Going the other direction, like you're doing here (using relatively expensive functions at rank 0 on relatively large arrays) is mostly going to bog down. Thanks, >>> -- >>> 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] Composition conjunctions
Even if Raul wouldn't consider them meaningful for some reason I don't understand it seems he should still understand that they are performance measurements? That I am creating a loop over a piece of code to measure the performance of this piece of code? /Erling On 2017-10-02 17:01, Don Guinn wrote: How many times do you have to be told that these kinds of measurements and meaningless? On Oct 2, 2017 8:57 AM, "Erling Hellenäs"wrote: How many times do I have to tell that I do this to measure performance? /Erling On 2017-10-02 16:39, Raul Miller wrote: Generally speaking, you want to push the large arrays into J's primitives as much as possible. Going the other direction, like you're doing here (using relatively expensive functions at rank 0 on relatively large arrays) is mostly going to bog down. Thanks, -- 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] Composition conjunctions
How many times do you have to be told that these kinds of measurements and meaningless? On Oct 2, 2017 8:57 AM, "Erling Hellenäs"wrote: > How many times do I have to tell that I do this to measure performance? > /Erling > > On 2017-10-02 16:39, Raul Miller wrote: > >> Generally speaking, you want to push the large arrays into J's >> primitives as much as possible. Going the other direction, like you're >> doing here (using relatively expensive functions at rank 0 on >> relatively large arrays) is mostly going to bog down. >> >> Thanks, >> >> > -- > 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] Composition conjunctions
How many times do I have to tell that I do this to measure performance? /Erling On 2017-10-02 16:39, Raul Miller wrote: Generally speaking, you want to push the large arrays into J's primitives as much as possible. Going the other direction, like you're doing here (using relatively expensive functions at rank 0 on relatively large arrays) is mostly going to bog down. Thanks, -- For information about J forums see http://www.jsoftware.com/forums.htm
Re: [Jprogramming] Composition conjunctions
Generally speaking, you want to push the large arrays into J's primitives as much as possible. Going the other direction, like you're doing here (using relatively expensive functions at rank 0 on relatively large arrays) is mostly going to bog down. Thanks, -- Raul On Mon, Oct 2, 2017 at 9:42 AM, Erling Hellenäswrote: > Hi all ! > > I tried to create explicit and tacit definitions of our composition > conjunctions. I think the result could possibly be used to clarify the > descriptions in NuVoc. > > Opinions are welcome, there are probably still some bugs or > misunderstandings of function, there could be interesting aspects to > discuss. > > The printout follows, then my project with definitions, tests and some minor > explanations. > > In the end of the printout there are some performance measurements. The > explicit versions are doing bad in those. The built in versions are slightly > faster, which could be expected. > > Cheers, > > Erling > > Printout=== > >ts=: 6!:2 , 7!:2@] NB. Time and space > >At=: 2 : 0 > NB. @: > u v"_ y > : > u x v"_ y > ) > > ┌─┐ > │_1 _2│ > └─┘ >NB. < _1_2 >5 ┌───┐ > │4 3│ > └───┘ >NB. < 4 3 > >NB. @: >AtTacit=: 2 : '[: u v' > > > ┌─┐ > │_1 _2│ > └─┘ >NB. < _1_2 >5 ┌───┐ > │4 3│ > └───┘ >NB. < 4 3 > >NB. @: > [: < - > >Atop=: 2 : 0 > NB. @ > u At v"v y > : > x u At v"v y > ) > > ┌──┬──┐ > │_1│_2│ > └──┴──┘ >NB. _1;_2 >5 ┌─┬─┐ > │4│3│ > └─┴─┘ >NB. 4;3 > >NB. @ >AtopTacit=: 2 : '([: u v)"v' > > ┌──┬──┐ > │_1│_2│ > └──┴──┘ >NB. _1;_2 >5 ┌─┬─┐ > │4│3│ > └─┴─┘ >NB. 4;3 > >NB. @ > ([: < -)"0 0 0 > ([: < [)"_ _ _ > ([: < i.)"1 _ _ > >Appose=: 2 : 0 > NB. &: > u v"_ y > : > (v"_ x) u v"_ y > ) > > ┌─┐ > │_1 _2│ > └─┘ >NB. < _1 _2 >5 ([:<<)Appose- 4 5 > ┌───┐ > │1 0│ > └───┘ >NB. < 1 0 > >NB. &: >ApposeTacitMonadic=: 2 : '[: u [: v ]' >ApposeTacitDyadic=: 2 : '([: v [) u [: v ]' > > ┌─┐ > │_1 _2│ > └─┘ >NB. < _1 _2 >5 ([:<<)ApposeTacitDyadic- 4 5 > ┌───┐ > │1 0│ > └───┘ >NB. < 1 0 > >NB. &: > [: < [: - ] >([:<<)ApposeTacitDyadic- > ([: - [) ([: < <) [: - ] > >Compose=: 2 : 0 > NB. & > u Appose v"v y > : > x u Appose v"v y > ) > > ┌──┬──┐ > │_1│_2│ > └──┴──┘ >NB. _1;_2 >5 ([:<<)Compose- 4 5 > ┌─┬─┐ > │1│0│ > └─┴─┘ >NB. 1;0 > >NB. & >ComposeTacitMonadic=: 2 : '([: u [: v ])"v' >ComposeTacitDyadic=: 2 : '(([: v [) u [: v ])"v' > > ┌──┬──┐ > │_1│_2│ > └──┴──┘ >NB. _1;_2 >5 ([:<<)ComposeTacitDyadic- 4 5 > ┌─┬─┐ > │1│0│ > └─┴─┘ >NB. 1;0 > >NB. & > ([: < [: - ])"0 0 0 >([:<<)ComposeTacitDyadic- > (([: - [) ([: < <) [: - ])"0 0 0 > >UnderRankInfinite=: 2 : 0 > NB. &.: > v"_^:_1 u v"_ y > : > v"_^:_1 (v"_ x) u v"_ y > ) > >-UnderRankInfinite> 1 2;3 4 > ┌─┐ > │_1 _2│ > │_3 _4│ > └─┘ >NB. <2 2 $ _1 _2 -3 -4 >(5;6) -UnderRankInfinite> 1 2;3 4 > ┌───┐ > │4 3│ > │3 2│ > └───┘ >NB. < 2 2 $ 4 3 3 2 > >NB. &.: >UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' >UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' > >-UnderRankInfiniteTacitMonadic> 1 2;3 4 > ┌─┐ > │_1 _2│ > │_3 _4│ > └─┘ >NB. <2 2 $ _1 _2 -3 -4 >(5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 > ┌───┐ > │4 3│ > │3 2│ > └───┘ >NB. < 2 2 $ 4 3 3 2 > >NB. &.: >-UnderRankInfiniteTacitMonadic> > [: >^:_1 [: - [: > ] >-UnderRankInfiniteTacitDyadic> > [: >^:_1 ([: > [) - [: > ] > >UnderRankV=: 2 : 0 > NB. &. > u UnderRankInfinite v"v y > : > x u UnderRankInfinite v"v y > ) > >-UnderRankV> 1 2; 3 4 > ┌─┬─┐ > │_1 _2│_3 _4│ > └─┴─┘ >NB. _1 _2; _3 _4 >(5;6) -UnderRankV> 1 2;3 4 > ┌───┬───┐ > │4 3│3 2│ > └───┴───┘ >NB. 4 3;3 2 > >NB. &. >UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v' >UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v' > >-UnderRankVTacitMonadic> 1 2; 3 4 > ┌─┬─┐ > │_1 _2│_3 _4│ > └─┴─┘ >NB. _1 _2; _3 _4 >(5;6) -UnderRankVTacitDyadic> 1 2;3 4 > ┌───┬───┐ > │4 3│3 2│ > └───┴───┘ >NB. 4 3;3 2 > >NB. &. >-UnderRankVTacitMonadic> > ([: >^:_1 [: - [: > ])"0 0 0 >-UnderRankVTacitDyadic> > ([: >^:_1 ([: > [) - [: > ])"0 0 0 > >n=.50 >v=.?~n >$v > 50 >10{.v > 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 > >ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' > 0.240852 1.32199e8 >ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' > 0.2369 1.322e8 >ts'-At-At-At-At-Atop- v' > 2.96161 1.32204e8 >ts'-@:-@:-@:-@:-@- v' > 0.158078 1.32197e8 > > == Project === > > ts=: 6!:2 , 7!:2@] NB. Time and space > > At=: 2 : 0 > NB. @: > u v"_ y > : > u x v"_ y > ) > > NB. < _1_2 > 5 NB. < 4 3 > > NB.
Re: [Jprogramming] Composition conjunctions
Hi all ! These measurements are with Jx j.dll on the latest Beta release. n=.50 v=.?~n $v 50 10{.v 50689 85238 136693 442735 25192 304048 139323 96663 216893 142946 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.1156 4.19917e6 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.108927 4.20006e6 ts'-At-At-At-At-Atop- v' 3.30635 4.20416e6 ts'-@:-@:-@:-@:-@- v' 0.115168 4.19712e6 For some reason my tacit code is on par with the built in code here. The performance of my tacit code is doubled!!! in this release compared to latest stable. There is no avx on this machine. I guess the Jx j.dll is compiled without it. The explicit code is even slower here. The measurements from the latest stable, taken from below: n=.50 v=.?~n $v 50 10{.v 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.240852 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.2369 1.322e8 ts'-At-At-At-At-Atop- v' 2.96161 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.158078 1.32197e8 Cheers, Erling On 2017-10-02 15:42, Erling Hellenäs wrote: Hi all ! I tried to create explicit and tacit definitions of our composition conjunctions. I think the result could possibly be used to clarify the descriptions in NuVoc. Opinions are welcome, there are probably still some bugs or misunderstandings of function, there could be interesting aspects to discuss. The printout follows, then my project with definitions, tests and some minor explanations. In the end of the printout there are some performance measurements. The explicit versions are doing bad in those. The built in versions are slightly faster, which could be expected. Cheers, Erling Printout=== ts=: 6!:2 , 7!:2@] NB. Time and space At=: 2 : 0 NB. @: u v"_ y : u x v"_ y ) 1 2;3 4 ┌─┐ │_1 _2│ │_3 _4│ └─┘ NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfinite> 1 2;3 4 ┌───┐ │4 3│ │3 2│ └───┘ NB. < 2 2 $ 4 3 3 2 NB. &.: UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' -UnderRankInfiniteTacitMonadic> 1 2;3 4 ┌─┐ │_1 _2│ │_3 _4│ └─┘ NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 ┌───┐ │4 3│ │3 2│ └───┘ NB. < 2 2 $ 4 3 3 2 NB. &.: -UnderRankInfiniteTacitMonadic> [: >^:_1 [: - [: > ] -UnderRankInfiniteTacitDyadic> [: >^:_1 ([: > [) - [: > ] UnderRankV=: 2 : 0 NB. &. u UnderRankInfinite v"v y : x u UnderRankInfinite v"v y ) -UnderRankV> 1 2; 3 4 ┌─┬─┐ │_1 _2│_3 _4│ └─┴─┘ NB. _1 _2; _3 _4 (5;6) -UnderRankV> 1 2;3 4 ┌───┬───┐ │4 3│3 2│ └───┴───┘ NB. 4 3;3 2 NB. &. UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v' UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v' -UnderRankVTacitMonadic> 1 2; 3 4 ┌─┬─┐ │_1 _2│_3 _4│ └─┴─┘ NB. _1 _2; _3 _4 (5;6) -UnderRankVTacitDyadic> 1 2;3 4 ┌───┬───┐ │4 3│3 2│ └───┴───┘ NB. 4 3;3 2 NB. &. -UnderRankVTacitMonadic> ([: >^:_1 [: - [: > ])"0 0 0 -UnderRankVTacitDyadic> ([: >^:_1 ([: > [) - [: > ])"0 0 0 n=.50 v=.?~n $v 50 10{.v 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.240852 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.2369 1.322e8 ts'-At-At-At-At-Atop- v' 2.96161 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.158078 1.32197e8 == Project === ts=: 6!:2 , 7!:2@] NB. Time and space At=: 2 : 0 NB. @: u v"_ y : u x v"_ y ) 1 2;3 4 NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfinite> 1 2;3 4 NB. < 2 2 $ 4 3 3 2 NB. &.: UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' -UnderRankInfiniteTacitMonadic> 1 2;3 4 NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 NB. < 2 2 $ 4 3 3 2 NB. &.: -UnderRankInfiniteTacitMonadic> -UnderRankInfiniteTacitDyadic> UnderRankV=: 2 : 0 NB. &. u UnderRankInfinite v"v y : x u UnderRankInfinite v"v y ) -UnderRankV> 1 2; 3 4 NB. _1 _2; _3 _4 (5;6) -UnderRankV> 1 2;3 4 NB. 4 3;3 2 NB. &. UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v' UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v' -UnderRankVTacitMonadic> 1 2; 3 4 NB. _1 _2; _3 _4 (5;6) -UnderRankVTacitDyadic> 1 2;3 4 NB. 4 3;3 2 NB. &. -UnderRankVTacitMonadic> -UnderRankVTacitDyadic> n=.50 v=.?~n $v 10{.v ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' ts'-At-At-At-At-Atop- v' ts'-@:-@:-@:-@:-@- v' -- For information about J forums see http://www.jsoftware.com/forums.htm -- For information about J forums
[Jprogramming] Composition conjunctions
Hi all ! I tried to create explicit and tacit definitions of our composition conjunctions. I think the result could possibly be used to clarify the descriptions in NuVoc. Opinions are welcome, there are probably still some bugs or misunderstandings of function, there could be interesting aspects to discuss. The printout follows, then my project with definitions, tests and some minor explanations. In the end of the printout there are some performance measurements. The explicit versions are doing bad in those. The built in versions are slightly faster, which could be expected. Cheers, Erling Printout=== ts=: 6!:2 , 7!:2@] NB. Time and space At=: 2 : 0 NB. @: u v"_ y : u x v"_ y ) 1 2;3 4 ┌─┐ │_1 _2│ │_3 _4│ └─┘ NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfinite> 1 2;3 4 ┌───┐ │4 3│ │3 2│ └───┘ NB. < 2 2 $ 4 3 3 2 NB. &.: UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' -UnderRankInfiniteTacitMonadic> 1 2;3 4 ┌─┐ │_1 _2│ │_3 _4│ └─┘ NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 ┌───┐ │4 3│ │3 2│ └───┘ NB. < 2 2 $ 4 3 3 2 NB. &.: -UnderRankInfiniteTacitMonadic> [: >^:_1 [: - [: > ] -UnderRankInfiniteTacitDyadic> [: >^:_1 ([: > [) - [: > ] UnderRankV=: 2 : 0 NB. &. u UnderRankInfinite v"v y : x u UnderRankInfinite v"v y ) -UnderRankV> 1 2; 3 4 ┌─┬─┐ │_1 _2│_3 _4│ └─┴─┘ NB. _1 _2; _3 _4 (5;6) -UnderRankV> 1 2;3 4 ┌───┬───┐ │4 3│3 2│ └───┴───┘ NB. 4 3;3 2 NB. &. UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v' UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v' -UnderRankVTacitMonadic> 1 2; 3 4 ┌─┬─┐ │_1 _2│_3 _4│ └─┴─┘ NB. _1 _2; _3 _4 (5;6) -UnderRankVTacitDyadic> 1 2;3 4 ┌───┬───┐ │4 3│3 2│ └───┴───┘ NB. 4 3;3 2 NB. &. -UnderRankVTacitMonadic> ([: >^:_1 [: - [: > ])"0 0 0 -UnderRankVTacitDyadic> ([: >^:_1 ([: > [) - [: > ])"0 0 0 n=.50 v=.?~n $v 50 10{.v 415593 299586 376558 161399 308885 477430 286004 354448 123594 75795 ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' 0.240852 1.32199e8 ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' 0.2369 1.322e8 ts'-At-At-At-At-Atop- v' 2.96161 1.32204e8 ts'-@:-@:-@:-@:-@- v' 0.158078 1.32197e8 == Project === ts=: 6!:2 , 7!:2@] NB. Time and space At=: 2 : 0 NB. @: u v"_ y : u x v"_ y ) 1 2;3 4 NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfinite> 1 2;3 4 NB. < 2 2 $ 4 3 3 2 NB. &.: UnderRankInfiniteTacitMonadic=: 2 : '[: v^:_1 [: u [: v ]' UnderRankInfiniteTacitDyadic=: 2 : '[: v^:_1 ([: v [) u [: v ]' -UnderRankInfiniteTacitMonadic> 1 2;3 4 NB. <2 2 $ _1 _2 -3 -4 (5;6) -UnderRankInfiniteTacitDyadic> 1 2;3 4 NB. < 2 2 $ 4 3 3 2 NB. &.: -UnderRankInfiniteTacitMonadic> -UnderRankInfiniteTacitDyadic> UnderRankV=: 2 : 0 NB. &. u UnderRankInfinite v"v y : x u UnderRankInfinite v"v y ) -UnderRankV> 1 2; 3 4 NB. _1 _2; _3 _4 (5;6) -UnderRankV> 1 2;3 4 NB. 4 3;3 2 NB. &. UnderRankVTacitMonadic=: 2 : '([: v^:_1 [: u [: v ])"v' UnderRankVTacitDyadic=: 2 : '([: v^:_1 ([: v [) u [: v ])"v' -UnderRankVTacitMonadic> 1 2; 3 4 NB. _1 _2; _3 _4 (5;6) -UnderRankVTacitDyadic> 1 2;3 4 NB. 4 3;3 2 NB. &. -UnderRankVTacitMonadic> -UnderRankVTacitDyadic> n=.50 v=.?~n $v 10{.v ts'-AtTacit-AtTacit-AtTacit-AtTacit-@- v' ts'-AtTacit-AtTacit-AtTacit-AtTacit-AtopTacit- v' ts'-At-At-At-At-Atop- v' ts'-@:-@:-@:-@:-@- v' -- For information about J forums see http://www.jsoftware.com/forums.htm