(b(i.~ ~.) a){ 0,~ #/.~a
1 0 3 3 1 2 2
R.E. Boss
-----Oorspronkelijk bericht-----
Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Namens Alex Rufon
Verzonden: donderdag 18 september 2008 16:39
Aan: Programming forum
Onderwerp: [Jprogramming] Verb Sequence or Ranking problem?
Hi.
I'm still at verb sequences and I have a question which I am guessing
that is more of a rank solution.
I have the following values:
[a=: 1 1 2 2 3 5 5 5
1 1 2 2 3 5 5 5
[b=: 3 4 5 5 3 1 2
3 4 5 5 3 1 2
What I wanted to do was count the number of matching numbers in a that
are in b. So potentially, my result should be:
1 0 3 3 1 2 2
Which if I append to the b noun, I should get:
3 1
4 0
5 3
5 3
3 1
1 2
2 2
I can actually solve this by using a for loop but that's what I'm trying
to avoid. So I reasoned that I can count by each number like so:
#I. a e. 5
3
#I. a e. 4
0
Using verb sequencing, I can recode this as:
a [EMAIL PROTECTED]@e. 5
3
a [EMAIL PROTECTED]@e. 4
0
So far so good. Now this is where I hit a snag, I tried to use the code
above against b and I get the following:
a [EMAIL PROTECTED]@e. each b
|length error
| a [EMAIL PROTECTED]@e.each b
a [EMAIL PROTECTED]@e. ,.b
0
a [EMAIL PROTECTED]@e. every b
|length error
| a [EMAIL PROTECTED]@e.every b
a [EMAIL PROTECTED]@e. "_ b
8
a [EMAIL PROTECTED]@e. "0 b
|length error
| a [EMAIL PROTECTED]@e."0 b
a [EMAIL PROTECTED]@e. "1 b
8
a [EMAIL PROTECTED]@e.@> (< every b)
|length error
| a [EMAIL PROTECTED]@e.@>(<every b)
a [EMAIL PROTECTED]@[EMAIL PROTECTED] (< every b)
|syntax error
| [EMAIL PROTECTED]@[EMAIL PROTECTED](<every b)
So as you can see, I still have a long way to go. :(
r/Alex
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm