Re: [Jprogramming] Removing annihilating pairs

2019-12-07 Thread Louis de Forcrand
3147776 Jasmin's solution is far too slow ts'(delitemG~ 2, 0 i.~ 2&(+/\))(^:_) 1 _1 2 _2{~1?.@#4' 1.2363434 1585408 Thanks for all the contributions R.E. Boss > -Oorspronkelijk bericht- > Van: Programming > Namens Louis de Forcrand > Verzonden: zaterdag 7 december

Re: [Jprogramming] Removing annihilating pairs

2019-12-06 Thread Louis de Forcrand
Not particularly J-ish, but (array-shuffling aside) linear solution: s=: ,`(1}.])@.(= -@{.)/ s 1 _1 2 _2{~100?.@#4 2 1 2 1 _2 _1 2 1 1 2 2 2 _1 2 _1 2 1 2 2 2 1 1 _2 _1 2 1 _2 _1 _2 _2 _2 _2 _1 _2 _1 _1 _2 _2 1 1 1 2 1 _2 1 _2 _1 _1 _1 2 Since the reduced form of the input list is unique,

Re: [Jprogramming] Removing annihilating pairs

2019-12-06 Thread Louis de Forcrand
If the answer to Jimmy's question is no, then the uniqueness of the resulting array has to do (surprisingly) with free groups (https://en.wikipedia.org/wiki/Free_group). Indeed we can view a vector of numbers as a word over the alphabet [0,∞) of positive real numbers (where negative numbers /

Re: [Jprogramming] Explicit vs tacit with assignment

2019-11-23 Thread Louis de Forcrand
t;>> there many times." >>> >>> We say "I lie down for a nap. I lie down, I lay down yesterday, I have >> lain >>> down..." >>> >>> the rest of the sentence was drowned out by cries of "No!". They had >> never &g

Re: [Jprogramming] (no subject)

2019-11-23 Thread Louis de Forcrand
I believe that as Devon said the subarray selected by m in x m} y must not contain any fill elements, which isn't the case of your example as in its case the first element of m specifies a length 4 vector while the other two elements specify length 2 vectors. This leads to a 2 by 2 matrix of

Re: [Jprogramming] Explicit vs tacit with assignment

2019-11-20 Thread Louis de Forcrand
Just to correct a mistake that I always hate making: "... for use after _its_ application ..." Sorry for the noise, Louis > On 21 Nov 2019, at 03:49, Louis de Forcrand wrote: > > (a,a=.?@#) is a verb, namely (?@# , ?@#). In this expression a is set to the > _ve

Re: [Jprogramming] Explicit vs tacit with assignment

2019-11-20 Thread Louis de Forcrand
(a,a=.?@#) is a verb, namely (?@# , ?@#). In this expression a is set to the _verb_ ?@# and then train (a,a) is evaluated. In the second case a is set to the _result_ of ?@# and then (a,a) is evaluated. To do this tacitly: (] , ]) @ (?@#) or more concisely ,~@?@# or equivalently (how I

Re: [Jprogramming] J and data structures

2019-11-19 Thread Louis de Forcrand
A simple use case which resembles the German-English dictionary is to implement variable-value bindings in a small interpreter. I've run into this many times in what I've been doing lately. Cheers, Louis > On 18 Nov 2019, at 19:38, Raul Miller wrote: > > Dictionaries might provide a useful

Re: [Jprogramming] Multiple Takes

2019-10-21 Thread Louis de Forcrand
Another (possibly lighter on memory) approach: ~. ; (#:i.2^4) <@(10 #. i.@!@# A. ])@# 0 1 2 6 Cheers, Louis > On 21 Oct 2019, at 01:09, Skip Cave wrote: > > Is there a less-verbose way to list all the integers (one-digit, two-digit, > three-digit, four-digit) can be formed by using the

Re: [Jprogramming] Sorry for the previous messages I neglected to remove from my reply

2019-10-14 Thread Louis de Forcrand
If this makes it any clearer, here is an implementation of /. key: key=: 1 : 0 =@[ u@# ] ) where = self-classify can itself be defined as sc=: ~. -:"_ _1"_1 _ ] Cheers, Louis > On 14 Oct 2019, at 21:26, Raul Miller wrote: > > I'm not sure what you mean, but consider: > > 'abcba'

Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Louis de Forcrand
I am missing something: a == 0 iff popcnt(a) == 0, so indeed a == 0 || b == 0 is equivalent to popcnt(a) == 0 || popcnt(b) == 0 which can be written as !(popcnt(a) && popcnt(b)), but if this is translated into a single-branch sequence of machine instructions, then wouldn’t !(a && b) be as well?

Re: [Jprogramming] A bit-twisting puzzle

2019-07-28 Thread Louis de Forcrand
Do we have access to an instruction which counts leading zero bits? Interesting problem, Louis > On 28 Jul 2019, at 19:51, Henry Rich wrote: > > Many of the members of this Forum will remember the days of assembler language > > ...and who could less than merry be > when writing out BXLE?

Re: [Jprogramming] newbie question about indexing/tabling

2019-07-13 Thread Louis de Forcrand
Quick correction: the answer given by Pascal is not 1019 but P(2166)-P(1019), and my email should use that instead of 1019 wherever it is mentioned. Sorry for the noise, Louis > On 14 Jul 2019, at 01:58, Louis de Forcrand wrote: > > I’m with Skip here: how do y’all guarantee that y

Re: [Jprogramming] newbie question about indexing/tabling

2019-07-13 Thread Louis de Forcrand
I’m with Skip here: how do y’all guarantee that your brute-force answers (which search through a list of the first few pentagonal numbers) actually return the pair with the smallest _difference_? How do you know there isn’t a pair outside your search range, where each number in the pair is much

Re: [Jprogramming] newbie question about indexing/tabling

2019-07-12 Thread Louis de Forcrand
Hi Daniel, If the ravel indices into the array M are stored in I, the multi-dimensional indices are then ($M) #: I So for your toy example a possible verb is v=: $ #: , I.@:= _1: Cheers, Louis > On 12 Jul 2019, at 02:11, Daniel Eklund wrote: > > Double thanks. > > One for that sparse

Re: [Jprogramming] How to improve speed searching for substrings using "E."?

2019-07-07 Thread Louis de Forcrand
k you for shedding the light on correct path. E.g. "P" can be > easily replaced to test for unordered subsets instead. Then another > dilemma, whether repeated part numbers are allowed on one line... > > Best regards, > Vadim > >> On Sat, Jul 6, 2019 at 5:35

Re: [Jprogramming] How to improve speed searching for substrings using "E."?

2019-07-05 Thread Louis de Forcrand
Hi again, I’m back with a speedier solution. comaxs is a conjunction, and if P is a boolean-valued dyadic verb and L any monadic verb on the items of the array A, P comaxs L A does the following: P and L are supposed to represent orderings on the elements of y. P represents a partial order,

Re: [Jprogramming] How to improve speed searching for substrings using "E."?

2019-06-30 Thread Louis de Forcrand
woops! Sorry, I changed the name of the adverb before sending the message (to something more descriptive than mxs3 :) but I forgot to switch the recursive call. Replace mxs3 by recmax and you should be good! Louis > On 30 Jun 2019, at 17:59, vadim . wrote: > > It's amazing. Thank you so

Re: [Jprogramming] How to improve speed searching for substrings using "E."?

2019-06-30 Thread Louis de Forcrand
Hi again, I haven’t much time right now, but I’ve come up with two new programs: fastmax=: 1 : 0 B=. C=. 1"_1 y while. +./C do. i=. C i.1 B=. 0 i} B B=.

Re: [Jprogramming] How to improve speed searching for substrings using "E."?

2019-06-30 Thread Louis de Forcrand
Hi, Try this: maxs=: 1 : 0 for_i. i.-#y do. if. (i{y) +./@:u (<< fast=: cmp maxs NB. fast fstr=: fast@(\: #@>)NB. faster? maxs is a generic adverb that takes a boolean-valued verb and an array. The verb represents a partial order on the elements of the array, and maxs returns the

Re: [Jprogramming] ambivalent tacit verb with Self-Reference

2019-05-05 Thread Louis de Forcrand
0 0 0 0| +-+---+ Sorry for the extra noise! Louis > On 5 May 2019, at 17:25, Louis de Forcrand wrote: > > Hi, > > Not exactly an answer to the question, but rather a cute way to pad an array > of any rank using a cool feature of ;. cut that I ran into today. > From the dictionary

Re: [Jprogramming] ambivalent tacit verb with Self-Reference

2019-05-05 Thread Louis de Forcrand
Hi, Not exactly an answer to the question, but rather a cute way to pad an array of any rank using a cool feature of ;. cut that I ran into today. From the dictionary: u;.0 y applies u to y after reversing y along each axis; it is equivalent to (0 _1 */$y) u;.0 y . Using this: padop=:

Re: [Jprogramming] Is there an 'inverse" to evoke

2019-05-03 Thread Louis de Forcrand
If you mean a textual representation of the array y, check ": . Otherwise if you want something like this var=: i.3 'var' -: v var 1 then I doubt that such a v exists. Cheers, Louis > On 3 May 2019, at 12:58, Piet de Jong wrote: > > If m is the name (ie string) of a variable then ‘m'~

Re: [Jprogramming] Applying different verbs to different items.

2019-05-03 Thread Louis de Forcrand
This subject regularly pops up every now and then, and it reminds me of something I wrote a little while back that might interest you. I found a couple of errors in them (oops) so I’m copying them here in hope that they are of help to you. They aren’t pretty or succinct but they work. (Code at

Re: [Jprogramming] complex x in Copy

2019-04-27 Thread Louis de Forcrand
Sorry! Misunderstood / read too fast. Devon’s using expand is the way to go. Does this do what you want? ]t=: 0,.#:0 14 14 0 0 0 0 0 0 0 1 1 1 0 0 1 1 1 0 0 0 0 0 0 (,t) #inv ,10+i.2 3 0 0 0 0 0 0 10 11 12 0 0 13 14 15 0 0 0 0 0 0 Hope this is better, Louis > On 27 Apr 2019, at 17:31,

Re: [Jprogramming] nubsieve modulo rotation

2019-02-17 Thread Louis de Forcrand
f=: |.~ 3 : 0 ... (explicit code here) is simply a hook which acts the same as g= |.~ t t=: 3 : 0 ... I was also very surprised to see this could be done the first time I ran into it! Cheers, Louis > On 17 Feb 2019, at 13:03, R.E. Boss wrote: > > I am embarrassed to admit I don't

Re: [Jprogramming] nubsieve modulo rotation

2019-02-13 Thread Louis de Forcrand
A possible version of the signature verb: sig=: |.~ >:@(# -~ {: i. 1:)@min min=: (_1 |. ] #^:_1 (= <./)@#~)^:(1 < +/@])^:a: 1"0 Perhaps not the fastest version, but it’s light on memory. Cheers, Louis > On 13 Feb 2019, at 18:52, Roger Hui wrote: > > Yes, well, left as an exercise for

Re: [Jprogramming] (no subject)

2018-12-16 Thread Louis de Forcrand
Hi, This is very similar to what you’re doing (you have to transpose the result to get exactly what you want): AC=: ({.~ -@>:@#) {~ #\ *"1 [: #:@i. 2 ^ # |:AC 'PNDQ' DD DD DD DD Q Q Q Q Q Q Q Q This one is quite cute if you don’t care about the

[Jprogramming] Class sort

2018-12-12 Thread Louis de Forcrand
Hi, R. E. Boss’s thread gave me an idea for an interesting problem: Given two vectors v and s of the same length, find the permutation w of v such that ((s=x)#w) -: /:~(s=x)#v for any scalar x in s. I have two solutions; the first is more obvious and relies on the key adverb and boxing,

Re: [Jprogramming] Cute solution

2018-12-12 Thread Louis de Forcrand
> On 12 Dec 2018, at 17:26, R.E. Boss wrote: > > Foo=: (\: %) Very nice! Here’s mine: Foo=: /: <&0 ,. ] Cheers, Louis -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Tacit form: How to handle intermediate result..?

2018-09-04 Thread Louis de Forcrand
I sent this message earlier today, but it seems that I used the wrong email address. I didn’t find it in the forum archives; sorry if it comes in twice. I see that most of what I said has since been covered by Mike. ~~~ I would’ve done it this way; the semi-perimeter is

Re: [Jprogramming] Control Words

2018-06-26 Thread Louis de Forcrand
Hi, If I understand your wording, you would like to generate n “multisets” of 6 random numbers which sum to 172. I say multiset because I imagine that order doesn’t matter, but that multiplicity does (so numbers can be repeated). If speed is a concern, then you could generate all possible

Re: [Jprogramming] Fifty Shades of J

2018-05-26 Thread Louis de Forcrand
I don’t know if this is the right place for this, but I just read through the beginning of a few sections, and looking at the one on groups I found the mathematical definition of a group kind of peculiar, in particular point (c): « every element e has a left and right inverse, that is there are

Re: [Jprogramming] Summing odd numbers

2018-05-15 Thread Louis de Forcrand
Since you have an even number of verbs in your train (1 and 2 are parsed as constant 1"_ and 2"_ verbs) the whole is interpreted as a hook, with the leading +/ taking its dyadic form. Your smodd1 verb is (in its monadic form) equivalent to ] +/ 1 + 2 * i. Since you want to apply +/ to the

Re: [Jprogramming] Goodstein Sequences and Hereditary base-n notation

2018-04-11 Thread Louis de Forcrand
Hi, This is my tacit version. Not claiming speed (or anything in the way of code legibility for that matter). The important verb is hbi, hereditary base-x incrementation of y used in creating the Goodstein sequence. My gs verb uses a starting base of 2, and gss starts with base x: hbi=: ([ (]

Re: [Jprogramming] Expression to generate sequ

2018-04-06 Thread Louis de Forcrand
Hi, Not a general answer about gerunds or tacit conditionals, but a particular solution for seq: seq=: [ + (* * i.@>:@|)@-~ 3 seq 7 3 4 5 6 7 3 seq~ 7 7 6 5 4 3 Cheers, Louis > On 6 Apr 2018, at 22:23, Devon McCormick wrote: > > Hi - > > I'm working with

Re: [Jprogramming] running count

2018-03-30 Thread Louis de Forcrand
Hiya, rc=: i.~ (] - {) /:@/: rc 1 2 1 1 2 0 0 1 2 1 Cheers, Louis > On 28 Mar 2018, at 20:32, Joe Bogner wrote: > > I think this is an easy one but it's escaping me. How to calculate a > running count of an item in a list? > > runct (1,2,1,1,2) -: 0,0,1,2,1 > runct

Re: [Jprogramming] On rank

2018-02-27 Thread Louis de Forcrand
Yes that is correct; u"n M always divides up into cells formed by grouping the last n dimensions together. Another way to see it is that elements of the array M who have the same (#$M) - n first indices are grouped together. A variant on u"n M is "(-n), which is roughly equivalent to

Re: [Jprogramming] How accurate is (o.) for arguments close to 0 or 1?

2018-02-27 Thread Louis de Forcrand
Try <.@%: . I believe it returns extended results on extended arguments. Cheers, Louis > On 27 Feb 2018, at 20:56, Don Kelly wrote: > > I agree with the series approach but the final result depends on division > which has limited accuracy. I would suggest using the following

Re: [Jprogramming] Unboxing problem

2018-02-18 Thread Louis de Forcrand
I believe you are looking for raze ( ; ). Cheers, Louis > On 18 Feb 2018, at 10:02, Arnab Chakraborty wrote: > > Hi, > > I have a list of boxes like > > m=. 1; 2 3 5; 4 5 > > All the boxes contain lists whose items have the same shape. So it is > meaningful to make a

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
know which of j expressions which could have matched original > expression you were referring to. > > Thanks, > > -- > Raul > > >> On Mon, Jan 29, 2018 at 12:39 PM, Louis de Forcrand <ol...@bluewin.ch> wrote: >> Yes, typed a little fast. >> &g

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
> Raul > > >> On Mon, Jan 29, 2018 at 12:31 PM, Louis de Forcrand <ol...@bluewin.ch> wrote: >> I skipped a few steps there. With pencil and paper, I find that (using >> standard notation) >> >> 2^(x+iy) = (1 +- sqrt(33)) / 2 >> >> Yet 2^(x+iy

Re: [Jprogramming] Another Quora Problem

2018-01-29 Thread Louis de Forcrand
. They are indeed arranged in a zigzag pattern on two vertical lines, and the one real solution occurs when k = 0. Cheers, Louis > On 29 Jan 2018, at 08:09, Louis de Forcrand <ol...@bluewin.ch> wrote: > > Note that if the equation really is (in traditional notation) > &

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Louis de Forcrand
Note that if the equation really is (in traditional notation) 4^x - 2^x - 8 = 0 then it can be rewritten as y^2 - y - 8 = 0, y = 2^x and solved in closed form as well, yielding a countably infinite set of solutions aligned along one (or two) vertical lines in the complex plane. (If I am not

Re: [Jprogramming] Another Quora Problem

2018-01-28 Thread Louis de Forcrand
Since Newton-Raphson is mentioned, I’d like to throw in (even though it might be mentioned on the wiki page) that VN=: 1 : 0 - u %. u D.1 ) is a kind of holy grail. It can iteratively find roots not only of complex scalar functions, but also complex vector and even tensor functions I

Re: [Jprogramming] Fill between curves using plot

2018-01-18 Thread Louis de Forcrand
You could try something with the polygon plot type. Assuming you have two sets of points, one for the top curve and one for the bottom curve, each in the usual form (xcoords;ycoords): 'poly' plot bot (, |.)&.> top might do something interesting. There may be other options like for opacity

Re: [Jprogramming] shortening a verbose expression

2018-01-06 Thread Louis de Forcrand
vec3=: [: ((* {.)~ , {:@[)/ 2 1 o.~/~ ] In the end though the most readable is probably Bo’s. No distracting array tricks. Louis > On 7 Jan 2018, at 02:26, Jimmy Gauvin wrote: > > This might be easier on the eyes: > > vc=:_2 */\ 1 2 1 1 2 o. 5 $ o. > > vc

Re: [Jprogramming] NaN, p., and control structures

2017-12-31 Thread Louis de Forcrand
Obviously nobody would ever enter if. 0 > _. them self. I guess if primitives never produce _. then we need not worry about it; but in the very slight off-chance that a bug lets one slip through, wouldn’t it be safer if an error is thrown? Anyhow, this topic’s problem is solved; gotta stay up

Re: [Jprogramming] NaN, p., and control structures

2017-12-29 Thread Louis de Forcrand
ppens when _. appears in an argument and spend no time worrying about > it. > > Henry Rich > > On 12/29/2017 10:50 PM, Louis de Forcrand wrote: >> Sorry for not trying this in j806, I should install it on my Mac. >> Will update. >> >> As for control structures treat

Re: [Jprogramming] NaN, p., and control structures

2017-12-29 Thread Louis de Forcrand
cause _. is not equal 0 so that > the condition is true. > > What is your code that treating _. as false? > > Also on my J806 linux64 > 2 7 p.1e308j_ > _j_ > > > Пт, 29 дек 2017, Louis de Forcrand написал(а): >> What about control structures treating _. as fa

Re: [Jprogramming] NaN, p., and control structures

2017-12-29 Thread Louis de Forcrand
intended. Put it on the bug list. > > Henry Rich > > On 12/29/2017 6:06 PM, Louis de Forcrand wrote: >> On the Indeterminate vocabulary page of the dictionary it is written >> >> The only ways to create _. are as follows: >> direct entry of _. >>

[Jprogramming] NaN, p., and control structures

2017-12-29 Thread Louis de Forcrand
On the Indeterminate vocabulary page of the dictionary it is written The only ways to create _. are as follows: direct entry of _. ". 3!:n DLL call (database, LAPACK, etc.) and Primitives on arguments not containing _. signal NaN error instead of producing _. .

[Jprogramming] viewmat export size

2017-12-19 Thread Louis de Forcrand
Hi, Does anyone know how to save a viewmat image to disk, and if so, how to chose the resulting image’s size? Thanks, Louis -- For information about J forums see http://www.jsoftware.com/forums.htm

Re: [Jprogramming] Euclidean Distance

2017-10-29 Thread Louis de Forcrand
I believe you can easily plot points in 3D space with lines betweens pairs of points: require 'plot' plot (; 2 ; 1) i:10j100 Cheers, Louis > On 28 Oct 2017, at 15:12, 'Skip Cave' via Programming > wrote: > > Thanks to Raul & Esa for their very clear instructions

Re: [Jprogramming] Partitions

2017-10-22 Thread Louis de Forcrand
I’ve been trying to simply count solutions. The best I could do is with the prime decomposition powers. Say we want to find the number of unordered solutions to n = */v solving for vector v where n is a scalar, and both are non-negative integers. Let p=: {: __ q: n. Then we need to “partition”

Re: [Jprogramming] load'plot'

2017-10-19 Thread Louis de Forcrand
Otherwise if you just want the plot package I believe the following works: load ‘pacman’ ‘install’ jpkg ‘search’ jpkg ‘plot’ You could make sure that ‘search’ jpkg ‘plot’ brings up only one result. Louis > On 19 Oct 2017, at 20:02, Raul Miller wrote: > > I think I

Re: [Jprogramming] Jx 1.1 Release

2017-10-08 Thread Louis de Forcrand
Maybe he didn’t understand your original question? In any case it seems you could use a lesson in good manners. Louis > On 8 Oct 2017, at 10:58, Erling Hellenäs wrote: > > Many people here have a habit of giving long lectures to people about things > they already

Re: [Jprogramming] (no subject)

2017-10-03 Thread Louis de Forcrand
Here is another approach using __: to generate only unique factors due to their unique prime factorisations: factors=: (*/ . ^ [: |:@:>@,@{ <@i.@>:)/@(__:) Cheers, Louis > On 3 Oct 2017, at 12:23, Erling Hellenäs wrote: > > Hi all! > > a=: 2 5 7 > f=: 1

Re: [Jprogramming] Composition conjunctions

2017-10-02 Thread Louis de Forcrand
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.

Re: [Jprogramming] Agenda in explicit expressions WAS: Tacit Expressions with Explicit J Syntax

2017-09-30 Thread Louis de Forcrand
That's what I understood from the J dictionary, NuVoc, and personal experience: $: refers to the *largest, unnamed, tacit* verb containing it. And by "tacit" here I mean in the same "colon-level" as the $: in question. For example: In $: @ (3 : 'y') $: refers to the whole verb. In 3 : '$: y' it

Re: [Jprogramming] Tacit Expressions with Explicit J Syntax

2017-09-28 Thread Louis de Forcrand
I don't really understand what you wish to add either, Erling. If you want to use explicit J syntax, you could write an explicit verb. You write: > Particularly to create what you most commonly need, a sequence of > monadic verbs, each acting on the result of the verb to the right. > Well, it is

Re: [Jprogramming] Ranges

2017-09-24 Thread Louis de Forcrand
You could compress twice: drng=: {.@[ (<: # ]) {:@[ (>: # ]) ] Perhaps faster on large data? You could reorder and filter out the data under the lower bound first if your data is usually smaller than it to speed up the verb. Louis > On 24 Sep 2017, at 22:37, Joey K Tuttle

Re: [Jprogramming] Gerund composed application

2017-09-24 Thread Louis de Forcrand
rob=: {: ,~ ({.[:`'') ,@,. }: g=: %:`*:`+: g +--+--+--+ |%:|*:|+:| +--+--+--+ rob g +--+--+--+--+--+ |[:|%:|[:|*:|+:| +--+--+--+--+--+ (rob g)`:6]5 10 "rob" transforms your gerund into a suitable train. You can then apply it with `:6. Cheers, Louis > On 24 Sep 2017, at 20:35,

Re: [Jprogramming] Quora Challenge

2017-09-16 Thread Louis de Forcrand
lnps=: 4 : 0 (i{p)+}.i.d{~i=. (i.>./)d=. 2-~/\p=. (<:x),(p:([+i.@-~)/_1 p:x,y),>:y ) Cheers, Louis > On 15 Sep 2017, at 18:24, Raul Miller wrote: > > Oh, oops... > > thru=: <. + i.@(+ *@+&0.5)@-~ > biggap=: {~ (0 1 + [: (i. >./) 2 -~/\ ]) > f=: [: thru/ 1 _1 + [: biggap

Re: [Jprogramming] Puzzling result

2017-09-10 Thread Louis de Forcrand
already almost >> used up (only 32-bit range is used to stay compatible with J32). The latest >> addition is literal4 in j805. IMO extended complex or extended complex >> rational are unlikely to be a candidate to use the nearly used up resource. >> >> On Sep 10, 2017

Re: [Jprogramming] Puzzling result

2017-09-09 Thread Louis de Forcrand
for? (Related: how would the exponential aspects > of complex number operations get handled?) > > Thanks, > > -- > Raul > > >> On Sat, Sep 9, 2017 at 4:57 AM, Louis de Forcrand <ol...@bluewin.ch> wrote: >> There is no extended complex datatype in J (although

Re: [Jprogramming] Puzzling result

2017-09-09 Thread Louis de Forcrand
There is no extended complex datatype in J (although its addition could be a thought). Louis > On 9 Sep 2017, at 09:23, 'Bo Jacoby' via Programming > wrote: > > >%2 NB. floating > 0.5 >x: %2 NB. extended > 1r2 >%1j1 NB. floating > 0.5j_0.5 >x: %1j1

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Louis de Forcrand
s doesn't: > > +/#~ -.@:(2&|)i.43 > > 22 > > Skip Cave > Cave Consulting LLC > >> On Tue, Aug 29, 2017 at 4:17 AM, Louis de Forcrand <ol...@bluewin.ch> wrote: >> >> Also count the verbs in >> >> #~ -. 2&| >> >> W

Re: [Jprogramming] Another Quora Problem

2017-08-29 Thread Louis de Forcrand
Also count the verbs in #~ -. 2&| With three verbs this evaluates to a fork, so (#~ -. 2&|) v (#~v) -. 2&|v which signals a length error because #~ changes the shape of its argument. What you want is to apply -. mondadically to 2&|, not apply it between #~ and 2&|; to do so use a cap [: like

Re: [Jprogramming] Another Quora Problem

2017-08-28 Thread Louis de Forcrand
Not built-in to the language. You could pretend to be the computer and expand tacit code yourself while referring to the dictionary, renaming chunks to help you. Otherwise there might be some code somewhere that does this, but I don't know of it. Good luck, Louis > On 29 Aug 2017, at 00:00,

Re: [Jprogramming] How to enclose two columns

2017-08-25 Thread Louis de Forcrand
In general, if you want to apply u along a group of n of axes: axis=: 2 : 0 u"(#n)@(n&|:) ) This is I believe very close to the axis operator in APL if you are familiar with it: ]m=: i.2 3 4 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 < axis 0 m

Re: [Jprogramming] "diagonals"

2017-08-15 Thread Louis de Forcrand
0 0 1 0 1 0 1 0 > 0 0 0 0 1 0 1 0 1 0 > 1 1 1 1 1 1 1 1 1 1 > 0 0 0 0 1 0 1 0 1 0 > 1 1 1 1 1 1 1 1 1 1 > 0 0 0 0 1 0 1 0 1 0 > 1 1 1 1 1 1 1 1 1 1 > 0 0 0 0 1 0 1 0 1 0 > > But I don't know which direction the diagonal elements would belong to. > > (And th

[Jprogramming] "diagonals"

2017-08-15 Thread Louis de Forcrand
Hi, Given an array index vector i, how would you go about finding efficiently all indices (or elements at them) of an array for which the index in each dimension is either the same as that in i, or is offset by +/- n, where n is the same for all dimensions, and keep them grouped by “direction”?

Re: [Jprogramming] Multidimensional Root Finding with Newton Solver

2017-08-10 Thread Louis de Forcrand
I find it interesting that N-R works for vectors and complex functions (and mixes of both). Just replace all those scalar functions by their vector equivalents: vn=: 1 : '- n * u %. u D.1' I added a scaling factor; it makes the convergence slower, but it fixes problems due to precision-loss.

Re: [Jprogramming] Fractional parts

2017-08-09 Thread Louis de Forcrand
gt; > >> On Wed, Aug 9, 2017 at 3:39 PM, Louis de Forcrand <ol...@bluewin.ch> wrote: >> A few handy tests which are good to know: >> >> N=: GI *. 1 0 e.~ * NB. naturals >> Z=: GI *. R NB. integers >> R=: = + NB. reals >> C_R=: + = - NB. pure

Re: [Jprogramming] Fractional parts

2017-08-09 Thread Louis de Forcrand
A few handy tests which are good to know: N=: GI *. 1 0 e.~ * NB. naturals Z=: GI *. R NB. integers R=: = + NB. reals C_R=: + = - NB. pure imaginaries (C-.R) GI=: = <. NB. gaussian integers These were made to accept any J number. They could be optimised if one knows that they are working only

Re: [Jprogramming] Boxed verbs as alternate gerunds

2017-08-07 Thread Louis de Forcrand
@.] should be used, not @.0 : v |value error: v v123 |value error: v123 v`''@.] v@.] v123`''@.] v123@.] I still like the @.] test. Louis > On 07 Aug 2017, at 19:26, Jose Mario Quintana > wrote: > > No joke was intended, undefined names are regarded

Re: [Jprogramming] "_1/

2017-08-07 Thread Louis de Forcrand
ner verb. > > In other words, -"_1 in -"_1 i.3 3 has an effective rank of 1, but in > -"_ i.3 it has an effective rank of 0. > > Since it can't know what rank to use until after it sees the nouns, > its announced rank has to be infinite. > > Thanks, > >

Re: [Jprogramming] "_1/

2017-08-07 Thread Louis de Forcrand
The same observations go for all operators which depend on their argument’s rank, such as @, &, or &. : <@(,"_1)~ i.3 ┌───┐ │0 0│ │1 1│ │2 2│ └───┘ Louis > On 07 Aug 2017, at 16:55, Louis de Forcrand <ol...@bluewin.ch> wrote: > > Yes I guess it could be re

Re: [Jprogramming] "_1/

2017-08-07 Thread Louis de Forcrand
+"_1 _ b.0 > _ _ _ > +"_1 _/~i.3 > 0 1 2 > 1 2 3 > 2 3 4 > > I'm not sure if it is the intended behavior. > > >> On Aug 7, 2017, at 3:40 PM, Louis de Forcrand <ol...@bluewin.ch> wrote: >> >> +"0/~ i.3 >> 0 1 2 >>

[Jprogramming] "_1/

2017-08-07 Thread Louis de Forcrand
+"0/~ i.3 0 1 2 1 2 3 2 3 4 +"_1/~ i.3 0 2 4 +"0 b.0 0 0 0 +"_1 b.0 _ _ _ I understand that this is dictionary compliant: "In general, each cell of x is applied to the entire of y . Thus x u/ y is equivalent to x u"(lu,_) y where lu is the left rank of u ." +"_1 b.0 _ _ _ So

Re: [Jprogramming] Jx version 1.0 release

2017-08-06 Thread Louis de Forcrand
l feature then > I would expect it to be a matter of adding a minor complication. > > Do you really need the cyclical feature? > > You might also like to read the oblique (/.) entry in the Dictionary and > other sources; it could help. > > > On Fri, Aug 4, 2017 at 1:0

Re: [Jprogramming] Fractional parts

2017-08-06 Thread Louis de Forcrand
ip would be best implemented as ip=: * * <.@| as it would return an integer result. Louis > On 06 Aug 2017, at 12:17, Skip Cave wrote: > > All, Thanks for the help. > > Here's some real numbers from a problem I'm working on: > Calculate some values from this

Re: [Jprogramming] Jx version 1.0 release

2017-08-03 Thread Louis de Forcrand
I quite like this idea. It’s unfortunate that m”n was previously defined differently, but as you say conflicts would probably be nonexistent, and I’ve often wanted to apply one verb to the first element of an array, another to the second, etc. On my wish list would be something similar for the

Re: [Jprogramming] Boxed verbs as alternate gerunds

2017-08-03 Thread Louis de Forcrand
Just wondering why isgerund=: 3 : 0 :: 0 y@.] 1 ) isn't an acceptable test for “gerundality”? I also kind of agree with Bill, in the sense that J doesn’t seem to have been designed from the ground up (or halfway up for that matter) to facilitate

Re: [Jprogramming] Everyone giving dollars to random others

2017-07-19 Thread Louis de Forcrand
NB. tacit run=: upd rec upd=: [ ((({~ 0{::]) + 1{::])`(0{::])`[} - 2{::]) ~.@] ; ] (+//. ; ]) 1 <: [ NB. explicit RUN=: UPD rec UPD=: 4 : 0 b -~ x u}~ (x {~ u=. ~.y) + y +//. b=. x >: 1 ) rec=: ((] + ] >: i.@[) (?@$ <:))@# Slower on short vectors, faster on larger ones (j805): 1e2 ts

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-19 Thread Louis de Forcrand
Sorry; I did digress from multiple assignment. Louis > On 19 Jul 2017, at 09:31, Raul Miller <rauldmil...@gmail.com> wrote: > > I believe that this discussion was about something different. > > Thanks, > > -- > Raul > >> On Wed, Jul 19, 2017 at 3:45

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-19 Thread Louis de Forcrand
> produce verbs, adverbs and conjunctions. >> >> [0] Tacit (unorthodox) version >>https://rosettacode.org/wiki/First-class_functions#Tacit_. >> 28unorthodox.29_version >> [1] Tacit (unorthodox) version >>https://rosettacode.org/wiki/First-class_fu

Re: [Jprogramming] Request for comments: multiple assignment

2017-07-17 Thread Louis de Forcrand
or Jx glitches. We were >> planning to wait for the official J806 to become stable and resolve the Jx >> glitches but I might decide instead to release a current version, as is, >> soon. >> >> >> On Mon, Jul 17, 2017 at 7:40 AM, Lo

Re: [Jprogramming] largest rectangle problem

2017-06-25 Thread Louis de Forcrand
1e6 ts'cs1 qqq' 0.045429 398080 ts'cs qqq' 0.180366 397440 Real fast! Louis > On 25 Jun 2017, at 14:47, Louis de Forcrand <ol...@bluewin.ch> wrote: > > Let V be a vector of real numbers, and V[i] its ith component. > Then > > min( V[i] … V[j+1] ) = min( min( V[i] …

Re: [Jprogramming] largest rectangle problem

2017-06-25 Thread Louis de Forcrand
Let V be a vector of real numbers, and V[i] its ith component. Then min( V[i] … V[j+1] ) = min( min( V[i] … V[j] ), min( V[i+1] … V[j+1] ) ). This version is based on that: ms=: #\ >./ . * [: >./@> # 2&(<./\&.>)&< ] 1e3 ts 'ms qq' 0.00491435 5.74234e6 Incorporating this in Mike's

Re: [Jprogramming] Complex residue

2017-06-23 Thread Louis de Forcrand
Thanks for the quick answers (and quick bug-fixing for that matter). Louis > On 23 Jun 2017, at 14:25, Henry Rich wrote: > > After reflection it seems clear that this is a bug in the implementation, so > I have fixed it for the next release, to match the Dictionary. > >

Re: [Jprogramming] Writing dyadic function with left/right parameters swapped

2017-06-03 Thread Louis de Forcrand
How about 1 0 1 0 1 0 (#~ ((-: & 0 1 0)"1 @: ({~ & z)))~ z ? You can then "simplify": First the hook (and {~) ([ #~ -:&0 1 0"1@:(z&{)@])~ ([ #~ -:&0 1 0"1@:(z&{)@])~ Then ~ can be "distributed" over the resulting fork: [~ #~ -:&0 1 0"1@:(z&{)@(]~) ] #~ -:&0 1 0"1@:(z&{)@[ You can keep going;

Re: [Jprogramming] J for iPad

2017-05-26 Thread Louis de Forcrand
Hi, Is this applicable to all devices running iOS? Thank you very much for the warning in any case. Louis > On 26 May 2017, at 11:43, Kip Murray wrote: > > My iPad Air now has iOS version 10.3.2 so I can no longer use J on my iPad. > --Kip Murray > > -- > Sent from

Re: [Jprogramming] Difference between jqt and JHS

2017-04-15 Thread Louis de Forcrand
Hi Linda, If you go to http://www.jsoftware.com/mailman/listinfo and choose your forum, you can then enter your email and subscription password in order to change subscription options. One of them is wether or not to recieve your own messages. Cheers, Louis > On 15 Apr 2017, at 21:38, Linda A

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread Louis de Forcrand
Hi Bo, This is cool. As for the way you suggest using it here, isn't it equivalent to (without the first six rows of your data): (~.@[ ,. +//.)/@|: ? Louis > On 12 Apr 2017, at 21:57, 'Bo Jacoby' via Programming > wrote: > > Hi Joe! > My favorite datastructure is

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread Louis de Forcrand
@gmail.com> wrote: > > Thanks Bo, Louis > > Louis - I will study your solution. J reports 'out of memory' on a million > rows. It is 6x faster than the larger data set too. Good solution! > >> On Thu, Apr 13, 2017 at 3:31 AM, Louis de Forcrand <ol...@bluewin.ch> wrote: &g

Re: [Jprogramming] matching & cancelling transactions

2017-04-13 Thread Louis de Forcrand
Try this. On my phone, it runs almost 6 times faster than your version on your small example data, but uses more space (maybe sparse matrices would be faster?), with: 1e3 timespacex 'applycredits' 0.000630182 4608 vs 1e3 timespacex 'ac t' 0.000131279 6400 Of course this extra space

Re: [Jprogramming] type/domain of an argument

2017-04-03 Thread Louis de Forcrand
A few useful shortcuts: isBoxed=: 0 < L. isChar=: {.@, e. a."_ isInt=: = <. isReal=: = + Louis > On 2 Apr 2017, at 14:43, 'Pascal Jasmin' via Programming > wrote: > > datatype or 3!:0 > > > datatype 3 4.1 0 > > > > > > From:

Re: [Jprogramming] Fast derivative of Softmax function

2017-02-27 Thread Louis de Forcrand
You probably know about it, but I'll mention it anyway: there's a primitive partial derivative operator in J. I think it would do exactly what you want (numerically), and it's probably reasonably fast. It's not too hard to use either: dsoftmax=: sm D.1 Louis > On 27 Feb 2017, at 10:20,

  1   2   >