Raul (Sat Jun 6 05:57:00 HKT 2009) posted the tacit expression
(~...@[ ,. +&.>//.)/ |:t1
to solve Havey's problem (Sat Jun 6 05:40:55 HKT 2009)
He followed up on (Sun Jun 7 06:23:27 HKT 2009)
with the modified tacit expression
((~...@[,.+&.>//.) ".&.>)/|:raultest
that fixed a problem with Harvey's data.
Forming tacit expressions with 1 : 0 offers two advantages.
Firstly, with 1 : 0 it's easy to modify a tacit program.
Secondly, tacit elements can be analysed to see that they
behave as expected. In this case +&.>/ is faulty.
raul=: 1 : 0
NB. (~...@[,.+&.>//.)/
a=. [: ~. [ NB. nub of left
b=. +&.>/
NB. this is equivalent to 1 (+&.>) 2(+&.>) 3 (+&.>) 4
NB. which is wasteful. The following is better.
b=. [: < [: +/ >
if. m -:'debug' do. b=. b f. :: ((<'failed')"_ ) end.
res=. a ,. b/. NB. put it together
res/ f. NB. apply adverb /
)
harvey=: 0 raul
harveyD=: 'debug' raul
harvey |: goodata
+-----+--+
|alpha|24|
+-----+--+
|beta |73|
+-----+--+
|delta|75|
+-----+--+
|gamma|22|
+-----+--+
|omega|37|
+-----+--+
harveyD |: badata
+-----+------+
|alpha|failed|
+-----+------+
|beta |73 |
+-----+------+
|delta|75 |
+-----+------+
|gamma|22 |
+-----+------+
|omega|37 |
+-----+------+
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm