Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

flattening recursive structures

Name: Anonymous 2018-10-02 7:05

assume that I'm parsing text to find definition of structures - things like A = [B, C, D]. the thing is: all those components can be structures themselves, defined elsewhere in this text: B = [X, Y, Z]. there are no guarantees of ordering: B can be defined before or after A. for reasons outside of my control, I don't have an access to any sort of 'end event' that tells me that all processing was done, I can only dump my outputs to a file and process it in another program once the first one exits.

now, I'd like to create a flat definition of a structure like A = [X, Y, Z, C, D]. this is easy enough to do but also a bit tedious and boilerplatey. the whole thing makes me want to just generate a set of Prolog rules, put them in a minimal template and have the language do it for me. but then I create a dependency on a whole Prolog runtime (which I'm not willing to use for the whole parsing process because that would be really fucking slow).

do any relatively mainstream languages have the kind of logic programming facilities that would make my job easy and non-tedious? or do I have to pick my poison between doing tree flattening by hand and requiring all users of my program to have Prolog?

Name: Anonymous 2018-10-02 7:47

Look into Haskell list comprehensions.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List