Split integer from atom in prolog -
i want split integer atom. ideas how that?
sample query:
?- split_int('nc(4)', n). % given: atom 'nc(4)' n = 4. % expected: integer 4
in swi prolog, should able like
?- term_to_atom( nc(n) , 'nc(4)' ). n = 4.
and want. in sicstus, looks need use library(codesio)
. should let this:
atom_to_term( , t ) :- atom_codes( , cs ) , read_from_codes( cs , t ) .
though you'll have ensure atom terminated period/full stop. 'nc(4)'
won't work, 'nc(4).'
work.
Comments
Post a Comment