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




-- 
*Kenneth Lettow*
Director Market Intelligence | Thomas™
Thomasnet.com <https://www.thomasnet.com> | #ThomasForIndustry
<https://www.thomasnet.com> <https://www.thomasnet.com>[image: Thomas For
Industry] <https://www.thomasnet.com>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to