That’s neater!

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

> On 29 Oct 2018, at 19:13, Raul Miller <[email protected]> wrote:
> 
> 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 http://www.jsoftware.com/forums.htm
>>> 
>>> 
>>> 
>> 
>> 
>> ---
>> This email has been checked for viruses by Avast antivirus software.
>> https://www.avast.com/antivirus
>> 
>> ----------------------------------------------------------------------
>> 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