[Jprogramming] empty results in list of paths
Raul Miller
rauldmiller at gmail.com
Fri Sep 5 23:02:34 HKT 2008
After a bit more thought (why did I use ^:a: instead of ^:_ and
what is the ending condition, and which paths are retained),
I think I have been tripping over a bug in J:
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.i.0 0 else.r end.
)
([: ; [: -.&a: <@(g&search_paths)"_ 1)&.>^:a: <,:_ 1
|attention interrupt
$@> ([: ; [: -.&a: <@(g&search_paths)"_ 1)&.>^:(i.10) <,:_ 1
1 2
2 3
1 4
0 0
0 0
0 0
0 0
0 0
0 0
0 0
That expression should terminate, but it does not.
Anyways, if you could describe your desired end result, we could
perhaps make some better suggestions.
For example, would this (or its raze) be
a suitable result?
+---+-----+-------+
|_ 1|5 1 2|5 1 2 3|
| |7 1 3| |
+---+-----+-------+
--
Raul
More information about the Programming
mailing list