On Fri, Sep 5, 2008 at 9:31 AM, Markus Schmidt-Gröttrup
<[EMAIL PROTECTED]> wrote:
> How must the results be combined other than with  ,/ such that empty path
> results just disappear?

The empty path is being produced by search_paths"_ 1
   g=:5 1 2,8 2 3,:7 1 3
   search_paths =: 4 : 0
NB. t =:  ending vertex not within path and starting vertex equals path end
t=.( -.({:"1 x) e. }.}: y)*.(1{"1 x)={:y
(({. y)<.t#{."1 x) ,.(}. y),"1 0 t#{:"1 x
)

   g&search_paths"_ 1&.>^:0 1 2 3 <,:_ 1
+---+-----+-------+-----+
|_ 1|5 1 2|5 1 2 3|     |
|   |7 1 3|       |     |
|   |     |0 0 0 0|     |
+---+-----+-------+-----+

You can eliminate them by explicitly discarding them
   ([: ; [: -.&a: <@(g&search_paths)"_ 1)&.>^:0 1 2 3 <,:_ 1
+---+-----+-------+-----+
|_ 1|5 1 2|5 1 2 3|     |
|   |7 1 3|       |     |
+---+-----+-------+-----+

Note also that boxing and razing achieves the same end as ,/

To deal with your termination problem, I think that you
should change your definition for search_paths:

search_paths =: 4 : 0
  NB. t =:  ending vertex not within path and starting vertex equals path end
  t=.( -.({:"1 x) e. }.}: y)*.(1{"1 x)={:y
  r=.(({. y)<.t#{."1 x) ,.(}. y),"1 0 t#{:"1 x
  if.0=#r do.,:y else.r end.
)
   _1 {:: ([: ; [: -.&a: <@(g&search_paths)"_ 1)&.>^:a: <,:_ 1
5 1 2 3
7 1 3 0

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to