Replies: 2 comments 7 replies
-
Wait, this does work. named_vars(VarNameIn, VarNameOut, Pred) :-
Pred=(foo(VarNameIn, VarNameOut) :- VarNameIn #= VarNameOut + 1).
?- named_vars(X, Y, Pred).
%@ Pred = (foo(X,Y):-X#=Y+1). Wait, lol. What? |
Beta Was this translation helpful? Give feedback.
1 reply
-
I did something similar in one of my projects (https://github.com/hurufu/ffmpeg-planner/blob/master/fol.prolog) Don't bother reading full project, because currently ChatGPT is 10000 times better at what I wanted that project to be :) But some parts are salvageable. I don't remember much detail, but if I recall correctly (and most probably I don't) the main idea was as follows:
|
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am working on transpiling lisp code to Prolog code. I have a question that I don't have the correct words for, and may not make sense.
For background, I may define a predicate in Clojure syntax as:
with the hopes that this would transpile to
To make the example really simple, this clearly does not work:
Would I need to do this with string formatting DCGs...?
I realize this may be asking the wrong question. If someone can help me figure out what the right question is, I'd appreciate it. I realize what I'm trying to do is in some ways nonsensical, it probably doesn't matter what the variables are named so long as they are logically distinct. But I haven't fully wrapped my head around the problem yet.
Update
Still confused, my question still doesn't make sense. I'd need to take a string and convert it to named variable, I think.
So,
This is what I meant to do.
Update 2
I think I've narrowed my question down to "how do I implement
string_term/2
:If we implement
string_term/2
as equality, we get:So close!
Update 3
After confusing the heck out of everyone, I realize I don't actually need this functionality right now. What I need to do is to convert a clojure string to a prolog string and then feed the prolog string into the shared library code.
At some point we should probably look into implementing
term_string/2
... but it is not this day!Beta Was this translation helpful? Give feedback.
All reactions