On Tue, Nov 28, 2017 at 9:31 PM, Daniel Lyons <[email protected]> wrote:
> That's kind of a cool idea. Is it commonly done, generating a block of code 
> in a string and evaluating it?

That's the basic concept behind compilers, though the way you've
phrased it here is slightly different.

That said, note that you can keep it as a block of code to be executed
as strings (".) or you could use it to define a verb (verb define) or
(3 :).

I'm not sure whether I'd do it this way, but if I did that's where I'd
be thinking. (Actually, I might do something like that to explore what
the solutions look like, but I'm not sure i'd stay with that
implementation once I understood.)

That said, I should also note that you can use transitive closure to
do a topological sort:
   order=. /: +/"1 (+. +./ .*~)^:_ graph
   ograph=. order { order {"1 graph
   odurations=. order { durations

This was not necessary in the examples shown so far - the graphs were
already sorted.

Thanks,

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

Reply via email to