I am working on revising an Einstein puzzle solving
program which currently is written as long while. loops, so
that the looping is minimized in the revision. I think the
answer to my question has been discussed in these forums as
a way to more efficiently calculate a result when the number
of different calculations is small relative to the length of
the list of data that is being operated upon. But I cannot
imagine how to search for that thread, so I have tried to
create a verb that shows the while. loop process in my
current program but does not resemble the real problem which
is more complex. I hope that with help on revising this
simplified problem to eliminate the while. loop, I can
master my real one.
Thank you,
e =: dyad define"1 2
assert. x -:&{.&$ y
w=. i. 0
while. #y do.
b=. {. y
z=. x|&{.b
select. z
case. 0 do. w=. w,+/b
case. 1 do. w=. w,*/b
case. 2 do. w=. w,>./b
case. do. w=. w
end.
x=.}.x
y=.}.y
end.
w
)
NB. more realistically the 5's below would be 300's.
NB. but this example is adequate, I hope
(5 ?...@$ 4) e 5 4 ?...@$ 20
52 19 38 30
(5 ?...@$ 4) ; 5 4 ?...@$ 20
+---------+-----------+
|2 3 3 0 2| 6 15 19 12|
| |14 19 0 17|
| | 0 14 6 18|
| |13 18 11 12|
| |18 0 10 2|
+---------+-----------+
2 3 3 0 2|6 14 0 13 18
0 2 0 13 0
--
(B=) <----------my "sig"
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm