erlang lists:dropwhile weird result -


can please me understand what's going on here

lists:dropwhile(fun(x) -> x < 8 end, lists:seq(1,10)).  "\b\t\n" % ??? ? why not [8,9,10]  lists:dropwhile(fun(x) -> x < 7 end, lists:seq(1,10)).    [7,8,9,10] % correct 

your results correct in both cases. unexpected string in first case due fact in erlang strings lists of integers. therefore, erlang chooses interpret first list string, since contains printable ascii codes. in second case list contains code 7, not printable, erlang forced interpret integer list.

you can print actual integer list using

mylist = lists:dropwhile(fun(x) -> x < 8 end, lists:seq(1,10)), io:format("~w", [mylist]). 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -