This is mo' bettah because it handles the empty case as well:

g=.4 : 'a$,y,.(a=.2$#y)$x'
   0 g 2 3 5 7
2 0 0 0
0 3 0 0
0 0 5 0
0 0 0 7
   '*' g 'plokijuhy'
p********
*l*******
**o******
***k*****
****i****
*****j***
******u**
*******h*
********y
   '' g ''
   $ '' g ''
0 0

Eldon Eller wrote:
> I wonder why f=.4 : 'a$,y,.(a=.2$$y)$x' did not work. It was copied
> directly from the J window. I just now pasted it from the email back
> into J and it ran OK. I am using J6.02 under linux.
>
> Ken Chakahwata wrote:
>   
>> Interesting -- I found I could extend the idea of "make matrix and rotate"
>> as follows, (this time without "each", using appropriate verb ranks):
>>
>> g=. ([: - [: i. #) |."0 1 # {."0 ]
>>
>> the empty case works as well, so:
>>
>>    $g 0$0
>> 0 0
>>    $g''
>> 0 0
>>
>> I found the dyad f below gives a domain error -- I tried to modify it, but
>> didn’t get too far.
>>
>> -----Original Message-----
>> From: [EMAIL PROTECTED]
>> [mailto:[EMAIL PROTECTED] On Behalf Of Eldon Eller
>> Sent: 13 October 2008 00:08
>> To: Programming forum
>> Subject: Re: [Jprogramming] diagonal arrays
>>
>> Or, dyadic:
>>
>> f=.4 : 'a$,y,.(a=.2$$y)$x'
>>
>>    0 f 2 3 5 7
>> 2 0 0 0
>> 0 3 0 0
>> 0 0 5 0
>> 0 0 0 7
>>    '-' f 'juytr'
>> j----
>> -u---
>> --y--
>> ---t-
>> ----r
>>
>> Björn Helgason wrote:
>>   
>>     
>>>       f=: 3 : 0
>>> ((#y),(#y))$ y ((1+#y)* i. #y) } ,((#y),(#y))$ ' '
>>> )
>>>    f 'abcdef'
>>> a
>>>  b
>>>   c
>>>    d
>>>     e
>>>      f
>>>
>>>
>>> 2008/10/12 Ken Chakahwata <[EMAIL PROTECTED]>
>>>
>>>   
>>>     
>>>       
>>>> I am looking at the various expressions contributed to date to see which
>>>> ones are general enough to handle a character vector right argument.
>>>>
>>>> enjoy
>>>> ken
>>>>
>>>> -----Original Message-----
>>>> From: [EMAIL PROTECTED]
>>>> [mailto:[EMAIL PROTECTED] On Behalf Of Raul Miller
>>>> Sent: 12 October 2008 18:35
>>>> To: Programming forum
>>>> Subject: Re: [Jprogramming] diagonal arrays
>>>>
>>>> On Sun, Oct 12, 2008 at 11:15 AM, Dan Bron <[EMAIL PROTECTED]> wrote:
>>>>     
>>>>       
>>>>         
>>>>>           (*=@/:)2 7 9 2
>>>>>       
>>>>>         
>>>>>           
>>>> Nice.
>>>>
>>>> I had been bothered by my earlier expression (* [EMAIL PROTECTED]@#) -- 
>>>> the [EMAIL PROTECTED] was
>>>> only
>>>> needed to ensure that values in each position were unique, and /: does
>>>>       
>>>>         
>> that
>>   
>>     
>>>> nicely.
>>>>
>>>> Thanks,
>>>>
>>>> --
>>>> Raul
>>>> ----------------------------------------------------------------------
>>>> 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
>>>     
>>>       
>> ----------------------------------------------------------------------
>> 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
>
>   
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to