That’s nice, too, and delivers this compact verb:

   V =: =/&i. NB. capital V to please Raul....
   3 V 10
1 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0 0

Thanks for that one, Linda,

Mike

Please reply to [email protected].      
Sent from my iPad

> On 29 Oct 2018, at 20:05, Linda Alvord <[email protected]> wrote:
> 
> 
> (i.3)=/i.10
> 1 0 0 0 0 0 0 0 0 0
> 0 1 0 0 0 0 0 0 0 0
> 0 0 1 0 0 0 0 0 0 0
> 
> 
> Linda
> 
> Sent from my Verizon, Samsung Galaxy smartphone
> 
> 
> -------- Original message --------
> From: Raul Miller <[email protected]>
> Date: 10/29/18 3:13 PM (GMT-05:00)
> To: Programming forum <[email protected]>
> Subject: Re: [Jprogramming] Binding x and y to an adverb (]})
> 
> Yeah, rotate has some fun possibilities, as does take.  For example:
> 
>   V=: (10 {. - {. 1:)@>:
>   V 0 1 2
> 1 0 0 0 0 0 0 0 0 0
> 0 1 0 0 0 0 0 0 0 0
> 0 0 1 0 0 0 0 0 0 0
> 
> Thanks,
> 
> --
> Raul
> On Mon, Oct 29, 2018 at 2:37 PM 'Mike Day' via Programming
> <[email protected]> wrote:
>> 
>> Posisbly the only virtue of this offering is that it's different from
>> Kenneth's!:
>> 
>>    va =: - (|."0 1) 1 ,. 0 $~ 9 ,~ #    NB. !!!
>> 
>>    va 1 2 3
>> 0 1 0 0 0 0 0 0 0 0
>> 0 0 1 0 0 0 0 0 0 0
>> 0 0 0 1 0 0 0 0 0 0
>> 
>>    va 0 3 7
>> 1 0 0 0 0 0 0 0 0 0
>> 0 0 0 1 0 0 0 0 0 0
>> 0 0 0 0 0 0 0 1 0 0
>> 
>> 
>> Mike
>> 
>> 
>> 
>>> On 29/10/2018 18:03, Kenneth Lettow wrote:
>>> Maybe something like this?
>>> 
>>> v=: (i.10)&e."_ 0
>>> 
>>> v 1 2 3
>>> 
>>> 0 1 0 0 0 0 0 0 0 0
>>> 
>>> 0 0 1 0 0 0 0 0 0 0
>>> 
>>> 0 0 0 1 0 0 0 0 0 0
>>> 
>>> v 0 1 2
>>> 
>>> 1 0 0 0 0 0 0 0 0 0
>>> 
>>> 0 1 0 0 0 0 0 0 0 0
>>> 
>>> 0 0 1 0 0 0 0 0 0 0
>>> 
>>> 
>>> 
>>> 
>>>> On Mon, Oct 29, 2018 at 1:57 PM, Lorenz Köhl <[email protected]> 
>>>> wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> I need a verb to turn a list of numbers between zero and nine
>>>> into a table where each item is 10$0 except at the place indexed
>>>> by the input numbers, for example:
>>>> 
>>>>    v 0 1 2
>>>> 
>>>> 1 0 0 0 0 0 0 0 0 0
>>>> 
>>>> 0 1 0 0 0 0 0 0 0 0
>>>> 
>>>> 0 0 1 0 0 0 0 0 0 0
>>>> 
>>>> My approach using ammend leaves me puzzled:
>>>> 
>>>> 
>>>> v=:1&(]})&(10$0)
>>>> 
>>>> v 1 2 3
>>>> 
>>>> 1 0 0 0 0 0 0 0 0 0
>>>> 
>>>> 1 1 0 0 0 0 0 0 0 0
>>>> 
>>>> 1 1 0 0 0 0 0 0 0 0
>>>> 
>>>> 
>>>> Here I have to bind two nouns (1 as x and 10$0 as y) to the verb
>>>> 
>>>> (]}) but maybe that doesn't do what I think it does? The rank of v
>>>> 
>>>> doesn't seem to matter, it gives the same output, but I know I want
>>>> 
>>>> it to use 0-cells of the input list.
>>>> 
>>>> 
>>>> I'd be happy to see what the idiomatic way to do this is, and maybe
>>>> 
>>>> how to fix my approach.
>>>> 
>>>> 
>>>> greetings,
>>>> 
>>>> Lorenz
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see 
>>>> https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7C49e86a34df9e4ee9428508d63dd29d72%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636764372120052101&amp;sdata=Ryc4dma7hARoqXQFIFdEsqY49bBEFy6oYCQuIiVpLeE%3D&amp;reserved=0
>>> 
>>> 
>>> 
>> 
>> 
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.avast.com%2Fantivirus&amp;data=02%7C01%7C%7C49e86a34df9e4ee9428508d63dd29d72%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636764372120052101&amp;sdata=DdpQ0%2F%2BlnPYtwzFNHnNkPMzol%2B2t8VL7WdFBwmqtd9A%3D&amp;reserved=0
>> 
>> ----------------------------------------------------------------------
>> For information about J forums see 
>> https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7C49e86a34df9e4ee9428508d63dd29d72%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636764372120052101&amp;sdata=Ryc4dma7hARoqXQFIFdEsqY49bBEFy6oYCQuIiVpLeE%3D&amp;reserved=0
> ----------------------------------------------------------------------
> For information about J forums see 
> https://nam01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.jsoftware.com%2Fforums.htm&amp;data=02%7C01%7C%7C49e86a34df9e4ee9428508d63dd29d72%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636764372120052101&amp;sdata=Ryc4dma7hARoqXQFIFdEsqY49bBEFy6oYCQuIiVpLeE%3D&amp;reserved=0
> ----------------------------------------------------------------------
> 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