Re: [Jprogramming] Quora Problem

2018-08-14 Thread Raul Miller
I do not see any attempt in the question at generalizing—so technically the answer would be a number. But I expect that easy to describe (but accurate) general approaches would fit right in... Thanks, — Raul On Tuesday, August 14, 2018, Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote

Re: [Jprogramming] Quora Problem

2018-08-14 Thread Jose Mario Quintana
After I saw your message I searched for the particular Quora problem and this is what I found, https://www.quora.com/What-number-must-be-subtracted-from-21-38-55-and-106-each-so-that-the-remainders-technically-differences-are-proportional It seems to me that the shape of the array is restricted t

Re: [Jprogramming] Quora Problem

2018-08-14 Thread 'Mike Day' via Programming
It should work on arrays of the form a + b * i, where a and b are integer scalars, and i is an integer vector. So, if q=: 6 + 7*1 2 5 11 23, applying this function yields (-/ .* % -/ .+)@:(2 2&$) q 7.4 I think you need instead something like Difference’s greatest common divisor,

Re: [Jprogramming] Quora Problem

2018-08-14 Thread Jose Mario Quintana
That post did not travel well; trying again, (-/ .* % -/ .+)@:(2 2&$)21 38 55 106 4 On Tue, Aug 14, 2018 at 5:30 PM, Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote: > > A direct solution without the assumption that the solution is a whole > number > > . > > . > > . > > (-/ .* %

Re: [Jprogramming] Quora Problem

2018-08-14 Thread Jose Mario Quintana
A direct solution without the assumption that the solution is a whole number . . . (-/ .* % -/ .+)@:(2 2&$) 21 38 55 106 4 On Tue, Aug 14, 2018 at 1:37 PM, Jose Mario Quintana < jose.mario.quint...@gmail.com> wrote: > A brute-force approach assuming that the solution is a whole number, and

Re: [Jprogramming] Calling C functions that take nested structures (by reference) in J

2018-08-14 Thread Joe Bogner
I have had success creating shim / interface DLLs that use a simpler, more portable interface strings or binary data (e.g. xml, json, msgpack[1]) instead of trying to lay things out in memory perfectly between J and C. Your shim DLL can take the json / xml or whatever and then parse it into the C s

Re: [Jprogramming] Calling C functions that take nested structures (by reference) in J

2018-08-14 Thread Raul Miller
You need to understand something about C to approach this problem. A big issue is that C structs have implementation specific rules about how they are laid out in memory. So that means either (a) studying how the C implementation lays out that struct in memory so you can write to memory directly,

[Jprogramming] Calling C functions that take nested structures (by reference) in J

2018-08-14 Thread Rodrigo de Azevedo
Dear J community, I am a novice. This is my first time posting here. I have a C function of the following type int parser(const char *str, Block *blck); where Block is a struct that has a nested array of structs. I would like to call this parsing function in J via a DLL. I have asked a question

Re: [Jprogramming] Quora Problem

2018-08-14 Thread Jose Mario Quintana
A brute-force approach assuming that the solution is a whole number, and I am understanding the problem correctly, follows after a few blank lines... ((0 = -/ .*@:(2 2$21 38 55 106 - ])"0) # ]) i.111 4 Checking, -/ .* (2 2$21 38 55 106 - 4) 0 Indeed, 17 is a commo

Re: [Jprogramming] Quora Problem

2018-08-14 Thread 'Mike Day' via Programming
Spot the non-deliberate editing error! M On 14/08/2018 16:16, Mike Day wrote: How about these snapshots? q =: 21, 38, 55, 106    }.+/\inv q NB. 1st differences 21 17 17 51    +./}.+/\inv q NB. gcd of 1st diffs 17 NB. or    2 -/\ q _17 _17 _51    +./2 -/\ q 17    17|q  NB. So, wha

Re: [Jprogramming] Quora Problem

2018-08-14 Thread 'Mike Day' via Programming
How about these snapshots? q =: 21, 38, 55, 106    }.+/\inv q NB. 1st differences 21 17 17 51    +./}.+/\inv q NB. gcd of 1st diffs 17 NB. or    2 -/\ q _17 _17 _51    +./2 -/\ q 17    17|q  NB. So, what is the required offset? 4 4 4 4    17%~ q-4 NB. what are the required factors

Re: [Jprogramming] How do I alter the width of hard-TAB in j807?

2018-08-14 Thread chris burke
Try set TabWidth=4 in the config, restart J so it picks up the setting, then in the terminal: (TAB,'123') fwrite '~temp/t1.ijs' In the editor, open the script and it should show 4 spaces before the '123'. On Tue, Aug 14, 2018 at 5:46 AM Don Guinn wrote: > Under Edit/Configure/QT ide I foun

Re: [Jprogramming] Quora Problem

2018-08-14 Thread Don Guinn
Brute force. >:I.1=(#@~.)"1(>:i.21)|/21 38 55 106 1 17 17|21 38 55 106 4 4 4 4 On Tue, Aug 14, 2018 at 12:08 AM Skip Cave wrote: > Attempting to solve the following Quora problem: > > What number must be subtracted from 21, 38, 55, and 106 each so that the > remainders (technically differenc

Re: [Jprogramming] How do I alter the width of hard-TAB in j807?

2018-08-14 Thread Don Guinn
Under Edit/Configure/QT ide I found TabWidth. It was blank. I assigned it a value of 2. Then edited a file and put a tab at the beginning. It showed up as one space in the editor but when I loaded the script and viewed it the tab took 2 spaces. It was still a tab. It was not converted to spaces. O