Odd:

1 </} 1 2 3,:2 2 2
1 1 3
2 2 2
   
   
   2 </} 1 2 3,:2 2 2
2 2 3
2 2 2
   
   123 </} 1 2 3,:2 2 2
123 2 3
  2 2 2
   
Linda

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Erling
Hellenäs
Sent: Monday, July 07, 2014 2:47 PM
To: [email protected]
Subject: Re: [Jprogramming] Tacit J and indexed replacement

An example:


x=:3 3 $i.9

y=:x+10

q=:2|x

x

0 1 2

3 4 5

6 7 8

y

10 11 12

13 14 15

16 17 18

q

0 1 0

1 0 1

0 1 0

q {"0 1 x,"0 y

0 11 2

13 4 15

6 17 8


/Erling

On 2014-07-07 19:53, Erling Hellenäs wrote:
> It's obviously not possible to do any amendments in tacit code? It is 
> also less elegant to pass these three parameters in the two arguments 
> in tacit code? Any opinions about the use of From to do the same thing?
>
> NB. x and y are arrays of the same rank
> NB. q is a boolean, also of this rank
> NB. The expression merges x and y.
> NB. Where q is TRUE it picks from y, otherwise x
> NB. q {"0 1 x,"0 y
>
> If q is a vector and if we actually have a variable z of rank 
> (+/q),}.$y we can easily create x from q#^:_1 [ z ? No use for any 
> indexes?
>
> /Erling
>
> On 2014-07-07 12:33, Raul Miller wrote:
>> Another approach for this is:
>>     (x*-.q)+y*q
>>
>> Sadly, that only works when x and y are numeric. Boxes and literals do
>> not have zero and 1 values (hypothetically "fill" could be zero, but
>> "1" is harder to rationalize.)
>>
>> A variant which uses amend might be:
>>     (q#y) (I.q)} x
>>
>> This only works when x and y are rank 1, but you could also use
>> something like this for higher ranked arrays:
>>     ($q)$ (q#&,y) (I.,q)} ,x
>>
>> (I hope I didn't make too many mistakes this time. I'm running without
>> any corrective support.)
>>
>> Thanks,
>>
>
> ----------------------------------------------------------------------
> 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

Reply via email to