Concatenating string and atom

Hello,

I need to concatenate a string with two atoms to obtain a hybrid string, such as:

A = "a"
B = '!'
C = label

and the end result should be:

"a"!label

I guess this could be an atom as well

'"a"!label'

but not:

\"a\"!label

or

'\"a\"!label'

somehow this eludes me, i can concatenate atoms or strings but how is it done for a combination …

any thoughts are much appreciated,

Dan

?- atomic_list_concat(['"',"a",'"','!',label],Result),atom(Result).
Result = '"a"!label'.

Does that work?

EDIT

If you prefer a string

?- atomics_to_string(['"',"a",'"','!',label],Result),string(Result).
Result = "\"a\"!label".

Thanks, Let me try …

Its somehow also complicated by how ~q and ~w are interpreted in a format string.

I noticed that if i pass both parts into format and use for one ~q and the other ~w and let it generate a string(S), then it seems to work.

I will also try your suggestion, so i can avoid a separate case.

thanks,
Dan

No, it didn’t work.

Its some quirk how ~q or ~w process the concatenated hybrid … seems to fall in-between the chairs. I need to process the string part with ~q and the atom part with ~w, so now i added another predicate where i pass the string and atom as to args, and format does the concatenation with the correct “format code”.

Seems to work that way
Dan