How to simulate atom_to_term(+Atom, -Term, -Bindings) of SWI-Prolog in SICStus Prolog?

StackOverflow https://stackoverflow.com/questions/20165720

  •  04-08-2022
  •  | 
  •  

Question

I am using SICStus Prolog to write a Dali agent and I need to convert an atom to a term but I can't use atom_to_term which is built in in SWI-Prolog

Était-ce utile?

La solution

Use library(codesio):

| ?- use_module(library(codesio)).
yes
?- set_prolog_flag(double_quotes,codes).
true.
| ?- read_from_codes("a(X,Y).",T).     

T = a(_A,_B) ? yes
| ?- read_term_from_codes("a(X,Y).",T,[variable_names(VN_list)]).
T = a(_A,_B),
VN_list = ['X'=_A,'Y'=_B] ?

In addition to that, you need atom_codes/2 which is ISO.

For more complex operations, you can open a stream with open_codes_stream/2. Which needs to be closed with close/1.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top