Search code examples
prologyap

prolog, how to correctly use escape sequences


I need (for design choices) to obtain a list who respects the following pattern:

Uses = ['foo\/1', 'foobar\/2'].

I'm able to build up the name/number pattern doing:

all((P\/A), (rule(X, Ux, _, Module), member(U, Ux), U = (P/A)), Uses).

where rule is an internal fact and Ux is a list.

I can escape slashes easily, using the '/' shortcut, but what about putting (P/A) between quotes?

How do that? please help me.


Solution

  • If you want to obtain 'foo/1', you can easily use atomic_list_concat/2 predicate as follows:

    Functor=foo,
    Arity=1,
    atomic_list_concat([Functor, '/', Arity], Output).
    

    In this way Output variable will be bound to 'foo/1' term.