Stated differently, the i. in the manual page for i. is different from
the i. you use in your programs and write at the terminal. The relation
between them is
i.(terminal) <=> i.(manual page)"1 /Erling
On 2017-12-13 20:53, Erling Hellenäs wrote:
Yes, as far as I understand when you execute a monadic rank 1 verb you
also execute an implicit rank adverb. At least that is how JWithATwist
works.
i. y <=> i."1 y
Same with all other J functions with a rank less than _ or _ _.
However, I think the scalar functions have different helper programs.
So, we have four helper programs. The monadic and dyadic rank adverb
and similar helper programs for monadic and dyadic scalar functions.
Pretty important to understand all about, including strange cases when
the arguments are empty.
/Erling
On 2017-12-13 19:18, Jose Mario Quintana wrote:
Apparently, TongKe Xue got an answer to his question (and even more);
but,
I have at least one of my own.
The Dictionary is the official reference and the (vocabulary) entry
for i.
( http://www.jsoftware.com/help/dictionary/didot.htm ). reads in part:
"
Integers i. 1
The shape of i.y is |y , and its atoms are the first */|y non-negative
integers.
"
However, for the case at hand,
Y=. 2 2 $ 1 2 3 4
$i.Y
2 3 4
|Y
1 2
3 4
This suggests to me that either the implementation is wrong or the
Dictionary is wrong (or at least too terse). Which one is wrong?
My guess is that the Dictionary claim about the shape and contents of
the
result is within the context of its rank (1). Why? Because for
non-negative
integers,
(i. -: (| $ i.@:(*/)@:|)("1))Y
1
Let us try one more level up,
Y=. 2 2 3 $ i.12
(i. -: (| $ i.@:(*/)@:|)("1))Y
1
This identity would also explain the padding (according to the entry for
$). In addition, the fact that JWithATwist implementation produces the
same result (at least for Y=. 2 2 $ 1 2 3 4) suggests to me that the
implementation is correct.
By default, I assume the Dictionary is right and I am wrong. Where did I
mess up?
On Wed, Dec 13, 2017 at 3:46 AM, Erling Hellenäs
<[email protected]>
wrote:
Yes.
(2 2 $ 1 2 3 4)
1 2
3 4
i.1 2
0 1
i.3 4
0 1 2 3
4 5 6 7
8 9 10 11
(i.1 2),: i.3 4
0 1 0 0
0 0 0 0
0 0 0 0
0 1 2 3
4 5 6 7
8 9 10 11
i. (2 2 $ 1 2 3 4)
0 1 0 0
0 0 0 0
0 0 0 0
0 1 2 3
4 5 6 7
8 9 10 11
I tried to describe this behavior in section "The Monadic Array
Operation
Helper Program" in this manual:
https://github.com/andrimne/JWithATwist.DocBook/raw/master/
target/en/JWithATwistReferenceManual.pdf
As far as my tests show J and JWithATwist behaves the same in this
regard.
I doubt you can find reasonably accurate descriptions of this
functionality (these four helper programs) anywhere else.
To understand J you have to understand this functionality, as I see
it. It
is essential in everything you do in J.
Cheers,
Erling Hellenäs
Den 2017-12-13 kl. 00:34, skrev 'Jon Hough' via Programming:
The zero-padding is happening because i. acts on each row but returns
different shaped results for each row.
Try this:
i.&.> <"1[2 2 $ 1 2 3 4
This will give boxed results of the correct shape for each row.
Another example of this kind of zero-padding is
q: 5 100000
q: will get the prime factors of each number. 5 only has one factor,
itself, whereas 100000 has many factors. J will zero pad
the result of q: 5 to match the shape of q: 100000.
Doing something like this:
q:&.> <"0[ 5 100000
will give non-zero-padded results. The results are boxed.
--------------------------------------------
On Wed, 12/13/17, TongKe Xue <[email protected]> wrote:
Subject: [Jprogramming] i. (2 2 $ 1 2 3 4)
To: [email protected]
Date: Wednesday, December 13, 2017, 7:49 AM
Hi,
I understand what (2 2 $ 1 2 3
4) does.
I understand what i. 1 2 does
I understand what i. 3 4 does.
I have read http://www.jsoftware.com/help/
jforc/loopless_code_i_verbs_have_r.htm#_Toc191734331
I understand the concept of
verb-rank, of frames + cells, of
"promoting one frame to another if they
share the same prefix."
I don't understand how the 0
padding in
i. (2 2 $ 1 2 3 4) works
What is the mechanism by which
0-padding is happening?
Thanks,
--TongKe
====
2 2 $ 1 2 3 4
1 2
3 4
i. 1 2
0 1
i. 3 4
0 1 2 3
4 5 6 7
8 9 10 11
i. (2 2 $ 1 2 3 4)
0 1 0 0
0 0 0 0
0 0 0 0
0 1 2 3
4 5 6 7
8 9 10 11
----------------------------------------------------------------------
For information about J forums see
http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm