I probably shouldn't show this version
>
> explicit_f =: dyad define
> result =. y
> for_repetition. i. x do.
> a =. 0 , result
> b =. a , 0
> c =. b ,. 0
>result =. 0 ,. c
> end.
> )
>
> > Date: Sun, 5 May 2019 07:36:11 +
> > From: Linda
Date: 5/5/19 2:50 PM (GMT-05:00)
To: programming
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Task: write f explicitly.
f=:(0 ,.~ 0 ,. 0 ,~ 0 , ])^:[
We try substituting x and y for [ and ] .
g=: 13 :'(0 ,.~ 0 ,. 0 ,~ 0 , y)^:x'
2 g i. 2 3
|domain error
ge-
From: Programming On Behalf Of
'robert therriault' via Programming
Sent: Sunday, May 5, 2019 3:45 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Hi Linda,
I think that the trick is that the left operand for ^: needs to be
ition. i. x do.
a =. 0 , result
b =. a , 0
c =. b ,. 0
result =. 0 ,. c
end.
)
Date: Sun, 5 May 2019 07:36:11 +
From: Linda Alvord
To:"programm...@jsoftware.com"
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Message-ID:
Content-Typ
Doh. padop can easily be a verb:
pad=: ];.0@((+$) {. ])^:2
2 1 pad&.> (i.2 3); i.2 2 2
+-+---+
|0 0 0 0 0 0 0|0 0 0 0|
|0 0 0 0 0 0 0|0 0 0 0|
|0 0 0 1 2 0 0|0 0 0 0|
|0 0 3 4 5 0 0|0 0 0 0|
|0 0 0 0 0 0 0| |
|0 0 0 0 0 0 0|0 0 0 0|
| |0 0 1 0|
|
Hi,
Not exactly an answer to the question, but rather a cute way to pad an array of
any rank using a cool feature of ;. cut that I ran into today.
From the dictionary:
u;.0 y applies u to y after reversing y along each axis; it is equivalent to (0
_1 */$y) u;.0 y .
Using this:
padop=: &((+
Hi Linda,
I think that the trick is that the left operand for ^: needs to be a verb. this
seems to work.
f=:(0 ,.~ 0 ,. 0 ,~ 0 , ])^:[
1 f i. 3 4
0 0 0 0 0 0
0 0 1 2 3 0
0 4 5 6 7 0
0 8 9 10 11 0
0 0 0 0 0 0
g=: 4 : '(0 ,.~ 0 ,. 0 ,~ 0 , ])^:x y'
1 g i. 3 4
0 0 0 0 0 0
0 0
can't define this function explicitly.
Linda
-Original Message-
From: Programming On Behalf Of Linda
Alvord
Sent: Saturday, May 4, 2019 9:28 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Messy but possible.
pad5=: 13 :'
pad5
4 : '(((x#0) ,"2 ((x#0) ,"2~ 0 (,"2) 0 ,"1~ (x#0) ,"1 ])) y)(,"2) (x#0)'
Linda
-Original Message-
From: Programming On Behalf Of Brian
Schott
Sent: Friday, May 3, 2019 12:36 PM
To: Programming forum
Subject: [Jprogramming] ambivalent tacit
Linda,
But, your solutions do not maintain the ambivalence of
pad =: (1&$:) : ((0,.~0,.0,~0,]) ^:[ )
Ambivalent pad can pad any number of zeros by employing the lefthand
argument.
To see the generality, experiment with alternatives like the following.
pad i. 2 3
1 pad i. 2 3
2 pad i. 2 3
---
(,"2) 0 ,"1~ 0 ,"1 ]
Linda
-Original Message-
From: Programming On Behalf Of Linda
Alvord
Sent: Saturday, May 4, 2019 10:58 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Also,
pad4=: 13 :'((0 ,"2 f) y)(,
rt therriault' via Programming
Sent: Friday, May 3, 2019 1:03 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Adding to Raul's solution, it can be simplified a little by removing the excess
]'s
pad =: (1&$:) : ((0,.~0,.0,~
Adding to Raul's solution, it can be simplified a little by removing the excess
]'s
pad =: (1&$:) : ((0,.~0,.0,~0,]) ^:[ )
pad i. 3 4
0 0 0 0 0 0
0 0 1 2 3 0
0 4 5 6 7 0
0 8 9 10 11 0
0 0 0 0 0 0
> On May 3, 2019, at 9:37 AM, Raul Miller wrote:
>
> pad =: (1&$:@]) : ((0,.~0,.
pad =: (1&$:@]) : ((0,.~0,.0,~0,]) ^:[ ])
Thanks,
--
Raul
On Fri, May 3, 2019 at 12:35 PM Brian Schott wrote:
>
> How do I create the verb `pad` below so that the first and the last
> expressions below produce the same result?
>
>pad =: (1&$:@]) : (0,.~0,.0,~0,]) ^:[ ]
>$ 1 pad i.
How do I create the verb `pad` below so that the first and the last
expressions below produce the same result?
pad =: (1&$:@]) : (0,.~0,.0,~0,]) ^:[ ]
$ 1 pad i. 3 4
5 6
$ 2 pad i. 3 4
7 8
$ pad i. 3 4
3 4 25 26
--
(B=)
--
15 matches
Mail list logo