Prolog - List of CharCodes to a String or Characters

后端 未结 3 911
难免孤独
难免孤独 2021-01-18 03:22

I have a list of Character Codes in prolog.

I would like to change them into characters.

For instance,

L = \"abc\" returns L = [9

3条回答
  •  清歌不尽
    2021-01-18 04:24

    Characters are represented as atoms of length 1. You can produce them:

    • At read time by changing the Prolog flag double_quotes. For more, see this and that link.

      :- set_prolog_flag(double_quotes, chars).
      
    • Dynamically, you can use atom_codes/2 and atom_chars/2. Or you can use char_code/2 directly.

提交回复
热议问题