I’m using: SWI-Prolog version 8.2
I have a multiway tree structure, and I was wondering what the prolog way is to reference internal nodes within the tree. I’m thinking of something like a key path, xpath, css selectors, or a lens (I haven’t directly used lenses, so I use it loosely here). I’d also like to have some sort of wildcard so that at certain levels you can match anything, and also possibly have a recursive wildcard (like **
).
I was thinking it might be a meta predicate, with a list of goals that are used to recurse into the tree?
Does anything along these lines exist?
thanks!
1 Like
There is library(xpath), but it requires your tree to have a bit unwieldy structure, namely each node must be element(Tag,Attributes,Children)
.
Of course it works fine for XML data, but a feature I was missing was the ability to navigate ‘backwards’. After a match, it’s difficult to locate the path without knowing the actual parent…
Anyway, if you want to get a taste of usage for simple understandable data (your file system tree), you could try
?- pack_install(dirtree).
and inspect the source with
?- edit(library(dirtree)).
( please forgive the shameless advertising )
HTH Carlo
Very interesting idea! I would very much like something along the lines of Clojure’s specter library for Prolog. I’m not aware of such a thing existing yet though.
It is definitely on my short-list of projects to do if I ever have free time.
OT
Following the meta link you posted, I stumbled on this interesting question, and the (summarized) answer
JS bundling is a best practice on HTTP/1.1, on HTTP/2 can be a bad practice in many cases
leave me dubious. Indeed, opening https://swi-prolog.discourse.group
is rather slow by today standards. What’s up with HTTP/2 ? Are the folks at meta doing it wrong ?
edit OT again
Sorry I tought you posted the link, seems instead it could be an artifact of recent addtiction of autolinking introduced on purpose of documentation. Indeed seems that every occurrence of the word meta get a (useless ?) link out there.
Anyway, for a SW engineering perspective, I would like to know if someone has advice about HTTP/2.
Yes it is getting a link added by Linkify words in post.
I removed meta from the list of words. Noteice that it is no longer a link.
Thanks.