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: g
|   (0,.~0,.0,~0,y)    ^:x


We see failure with power.
We look up power in NuVoc
[x] u^:n y     Fixed Power     Conjunction

Oh!  ^: requires a non-noun on its left (u) and a noun y to the right (n).
j computes (0 ,.~ 0 ,. 0 ,~ 0 , y) as a noun, and sure enough, domain error.

We might choose

g=: 13 :'(0 ,.~ 0 ,. 0 ,~ 0 , ])^:x y'

or

frame=: 13 :'(0 ,.~ 0 ,. 0 ,~ 0 , y)'
h=: 13 :'frame^:x y'



   NB. successful tests, g and h match f.

   (i.8) (g -: f)"0 _ i. 2 3
1 1 1 1 1 1 1 1

   (i.8) (h -: f)"0 _ i. 2 3
1 1 1 1 1 1 1 1

At least, that's how I did it, and 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 +0000
From: Linda Alvord<[email protected]>
To:"[email protected]"  <[email protected]>
Subject: Re: [Jprogramming] ambivalent tacit verb with Self-Reference
Message-ID:
        
<byapr10mb37353d62a16c9d17d4e6dbe3b5...@byapr10mb3735.namprd10.prod.outlook.com>
        
Content-Type: text/plain; charset="utf-8"

Here's a simple function:

f=:(0 ,.~ 0 ,. 0 ,~ 0 , ])^:[
3 f i.3 4
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  0 0 0 0
0 0 0 0 1  2  3 0 0 0
0 0 0 4 5  6  7 0 0 0
0 0 0 8 9 10 11 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 0 0  0  0 0 0 0
But, oddly, I can't define this function explicitly.

Linda

-----Or
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to