> On Nov 28, 2017, at 7:11 PM, Henry Rich <[email protected]> wrote:
> 
> You're right about the last bit - you can't start with a transitive closure.  
> I missed that.
> 
> Suppose you turn each dependency into a J sentence, say
> 
> a =: 5
> 
> or
> 
> c =: longerof (a , b)
> 
> or
> 
> f =: a following (e , g)
> 
> or combinations thereof.  There must be no loops in the dependencies, so you 
> could do a topological sort on the tasks, to ensure that each assignment 
> refers only to names that have already defined.  Then just execute the sorted 
> script and see the results.
> 
> You would need the definitions
> 
> longerof =: >./
> following =: +
> 
> and you need a topological sort, which isn't too hard.  I know I wrote one 
> for the Advent of Code problems a couple of years ago.


That's kind of a cool idea. Is it commonly done, generating a block of code in 
a string and evaluating it?

-- 
Daniel Lyons




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

Reply via email to