It's unusual to create a whole program and run it. It's not at all
unusual to create a sentence and run it (using ". y). In an interpreted
language the distinction between 'code' and 'data' doesn't have to be sharp.
Henry Rich
On 11/28/2017 9:31 PM, Daniel Lyons wrote:
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?
---
This email has been checked for viruses by AVG.
http://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm