2

In my erlang web application, there is a list, which contains integers to be printed on the web page. But when the script executes, it prints this, instead of actual list,

Please look at this Image showing characters for unicode codepoint 1, 1, 2, 3, 5, 8, whitespace, codepoint 15

How to format this to gain what I want? Target list is [1, 1, 2, 3, 5, 8, 13, 15]

ndim
  • 35,870
  • 12
  • 47
  • 57
indranama
  • 1,183
  • 2
  • 9
  • 6
  • Imageshack is blocked in China. You should think about using decentralized services, why not your own FTP ? Remember the Skype bug a few days ago... – Tangui Jan 04 '11 at 15:45
  • @Tangui: If http://imgur.com ain't blocked in China, one may use it right from within SO interface (button *Image* or keyboard shortcut Ctrl+G). – YasirA Jan 04 '11 at 15:52
  • 1
    try with [1, 1, 2, 3, 5, 8, 13, 21] ;) sorry;) couldnt resist. – user425720 Jan 04 '11 at 19:45
  • @ Tangui, I'm sorry mate. Next time I'll do that. – indranama Jan 05 '11 at 09:31

2 Answers2

6

You should do this:

P = [1, 1, 2, 3, 5, 8, 13, 15],
Show_on_page = io_lib:format("~p",[P]),
Show_on_page.

This will represent any Erlang term on the web page the way you want to see it.

Jonas
  • 121,568
  • 97
  • 310
  • 388
Muzaaya Joshua
  • 7,736
  • 3
  • 47
  • 86
2

You Web presentation probably like the values more converted to string (lists).

1> [ integer_to_list(I) || I <- [1,1,2,3,5,8,13,15] ].
["1","1","2","3","5","8","13","15"]

Maybe join them as well depending on your formatting.

2> string:join([ integer_to_list(I) || I <- [1,1,2,3,5,8,13,15] ],",").
"1,1,2,3,5,8,13,15"
D.Nibon
  • 2,883
  • 1
  • 19
  • 17