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

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -