[Jprogramming] Outer product (APL)
Mike Day
mike_liz.day at tiscali.co.uk
Sat Apr 2 07:37:30 UTC 2016
Do these examples help?
a (<@,/ )b NB. your original, but boxed
+-------------+
|0 1 2 0 1 2 3|
+-------------+
a (<@,"0/ )b NB. what you're seeking?
+---+---+---+---+
|0 0|0 1|0 2|0 3|
+---+---+---+---+
|1 0|1 1|1 2|1 3|
+---+---+---+---+
|2 0|2 1|2 2|2 3|
+---+---+---+---+
3 (<@,"0/ &i. )4 NB. can embed the iota
+---+---+---+---+
|0 0|0 1|0 2|0 3|
+---+---+---+---+
|1 0|1 1|1 2|1 3|
+---+---+---+---+
|2 0|2 1|2 2|2 3|
+---+---+---+---+
Apologies if these don't display well - they look
ok in draft.
Mike
On 02/04/2016 08:11, Gian Medri wrote:
> Hi !
>
> In J the outer product has the form: a foo/ b.
> It doesn't work for comma.
> Example
> a=: i. 3
> b=: i.4
> [ a ,/ b
> 0 1 2 0 1 2 3
> APL
> a °. , b
> 0 0 0 1 0 2 0 3
> 1 0 1 1 1 2 1 3
> 2 0 2 1 2 2 2 3
>
> 3 x 4 boxed result
>
> Can I have the same result in J as easily as in APL?
> Best regards
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
More information about the Programming
mailing list