Erlang on Windows List Comprehension multiply gives “\f”

后端 未结 2 1473
春和景丽
春和景丽 2021-01-25 22:23

Hi i have a weird problem with Erlang on Windows i am running 16B and WinXP.

I have the following code

-module(test).
-export([cost/1,total/1]).
cost(ora         


        
2条回答
  •  面向向阳花
    2021-01-25 22:37

    A string is a list of integers. The value you're returning is a list of integers.

    Erlang uses a simple heuristic for when to show something as a string, or as a list of integers: is it a flat list containing only numbers in the range {55,250}. (I made those numbers up, but it's something like that. If there are control characters or low characters, it bails.)

    Since Erlang doesn't do this to tuples, tuples make it easy to see.

    1> {72,101,108,108,111,44,32,83,116,101,112,104,101,110,46}.
    {72,101,108,108,111,44,32,83,116,101,112,104,101,110,46}
    
    2> [72,101,108,108,111,44,32,83,116,101,112,104,101,110,46].
    "Hello, Stephen."
    

    Erlang is just guessing wrongly what's inside the list.

    HTH.

提交回复
热议问题