c=:0 1; 0 3;1 2;2 0;3 0
1 c} m
0 1 0 1
0 0 1 0
1 0 0 0
1 0 0 0
2006/11/26, Kairit Sirts <[EMAIL PROTECTED]>:
Hi!
But now another problem:
> a =: ;: 'he ha ho he hi he'
> b =: ~. a
c =: 1 4; 2 ; 3; 5
> d =: c { each <b i. a
> +---+-+-+-+
> |1 3|2|0|0|
> +---+-+-+-+
>
Now I have the following matrix:
m =: ((#b), #b) $ 0
and I have to fill it based on the information in d. Each cell of d
corresponds to each row of m. Indexes in cells show which positions in
that
row in m should be incremented by one.
After this procedure using example data above the m should look the
following:
m
0 1 0 1
0 0 1 0
1 0 0 0
1 0 0 0
I studied the vocabulary and the following verbs seem to be useful for
this
task:
Dyad {:: for selecting items from d, but I understand that it cannot be
used
for selecting several items (for example i.3 {:: d).
m} for amending the matrix elements, but how to use it for replacing the
cell value with the current cell value + 1?
Any other suggestions, which verbs to use and how to combine them to get
the
task done?
Kairit
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
Björn Helgason, Verkfræðingur
Fugl&Fiskur ehf, Þerneyjarsund 23, Box 127
801 Grímsnes ,t-póst: [EMAIL PROTECTED]
Skype: gosiminn, gsm: +3546985532
Landslags og skrúðgarðagerð, gröfuþjónusta
http://groups.google.com/group/J-Programming
Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
góður kennari getur stigið á tær án þess að glansinn fari af skónum
/|_ .-----------------------------------.
,' .\ / | Með léttri lund verður |
,--' _,' | Dagurinn í dag |
/ / | Enn betri en gærdagurinn |
( -. | `-----------------------------------'
| ) | (\_ _/)
(`-. '--.) (='.'=)
`. )----' (")_(")
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm