[Jprogramming] towards a reshape arguments adverb
Linda A Alvord
lindaalvord at verizon.net
Fri Sep 25 02:34:08 UTC 2015
I tend to favor verbs:
f=: 13 :'(($i.y)#x);i.y'
7 f 5
┌─────────┬─────────┐
│7 7 7 7 7│0 1 2 3 4│
└─────────┴─────────┘
f
([ #~ [: $ [: i. ]) ; [: i. ]
Linda
-----Original Message-----
From: programming-bounces at forums.jsoftware.com [mailto:programming-bounces at forums.jsoftware.com] On Behalf Of 'Pascal Jasmin' via Programming
Sent: Thursday, September 24, 2015 10:05 PM
To: Programming Forum
Subject: [Jprogramming] towards a reshape arguments adverb
for vectors, this is ok
7 (([ $~ >.&# ) ; ] $~ >.&#) i.5
┌─────────┬─────────┐
│7 7 7 7 7│0 1 2 3 4│
└─────────┴─────────┘
I thought this should work too though.
7 ;&($~ >.&#) i.5
┌─┬─────────┐
│7│0 1 2 3 4│
└─┴─────────┘
Is there a way to chain & to get first result?
On another note, if you imagine a language that doesn't have a rank conjunction, or shape compatibility concepts, you would have to reshape for them.
7 6 + i.2 5
7 8 9 10 11
11 12 13 14 15
2 5 $ 5 # 7 6
7 7 7 7 7
6 6 6 6 6
can you make an adverb that reshapes the right argument such that a rank0 verb would produce a sensible result, or more impressive, reshape both arguments if they are incompatible to reproduce "0 1 behaviour? ie.
7 6 +/ i.5
7 8 9 10 11
6 7 8 9 10
which is
(2 5 $ 5 # 7 6 ) + 2 # ,: i.5
7 8 9 10 11
6 7 8 9 10
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list