My apologies if the following does not align properly
- it displays OK on my screen here ...
z=:i.3 4 NB. Rank 2 example
3 (,:"_ ; ,:"_ 1 ; ,"_ 0) z NB. J equiv of ,[-0.5] ,[0.5] ,[1.5]
------T------T--┐
│3 3 3 3│3 3 3 3│3 0│
│3 3 3 3│0 1 2 3│3 1│
│3 3 3 3│ │3 2│
│ │3 3 3 3│3 3│
│0 1 2 3│4 5 6 7│ │
│4 5 6 7│ │3 4│
│8 9 10 11│3 3 3 3│3 5│
│ │8 9 10 11│3 6│
│ │ │3 7│
│ │ │ │
│ │ │3 8│
│ │ │3 9│
│ │ │3 10│
│ │ │3 11│
L-----+------+---
$&.> 3 (,:"_ ; ,:"_ 1 ; ,"_ 0) z
----T---T---┐
│2 3 4│3 2 4│3 4 2│
L---+---+----
NB. Note above the new axis position (2) relative to the shape (3 4)
NB. ie (2) 3 4 ; 3 (2) 4 ; 3 4 (2)
NB. so the last example requires catenate with scalar right arg
The above corresponds to the given APL expressions on my PC.
...Regards Rob
-----Original Message-----
From: [EMAIL PROTECTED] [ <mailto:[EMAIL PROTECTED]>
mailto:[EMAIL PROTECTED] On Behalf Of Miller, Raul D
Sent: Thursday, 10 August 2006 2:02 AM
To: General forum
Cc: PackRat
Subject: [Jgeneral] RE: [Jprogramming] Newbie Q re: lamination and
userinteraction
PackRat wrote:
> Actually, I very deliberately had both a negative and positive example
> to see how to handle both cases. The original code had the negative.
> The reason behind this portion of my question was that I was wondering
> whether the negative axis-specifier meant (as in other APL commands)
> working from the last dimension backward and how this would
> look in J. My guess was that the _0.5th dimension might
> have been a new last or next-to-last dimension, but you
> didn't seem to address that question. Is that the case,
> or what? And, if so, how would it look in J?
I doubt the J programming forum is the right place to be
asking about the precise distinction between the
APL fragments ,[-0.5] and ,[0.5]. So, I've taken the
liberty of responding using the general forum.
Personally, I'm not even sure I know the answer -- I've
not used APL since the last millennium.
If we are being precise, ,[-0.5] is probably like
,:"_1 and ,[0.5] is probably like ,:"1. This assumes
that I've remembered my APL correctly, and assumes
quadIO is zero.
Note also that other, simpler expressions might also
be equivalent, depending on the problem domain.
A completely mechanical translation of APL to J would
likely involve a number of rather complicated expressions
which are designed to implement APL literally in J. For example, to emulate
quadIO, you'd need a more complicated expression than ,:"1, and most of the
time you would be far better off picking a J expression which was chosen
with knowledge of what quadIO value was intended for the APL code.
Finally, if you don't know what the APL code does, you
might be better off writing the J code from first principles (instead of
trying to translate something you don't understand).
--
Raul
----------------------------------------------------------------------
For information about J forums see <http://www.jsoftware.com/forums.htm>
http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm