I am new with functional programming languages and I can’t understand why in Erlang, if I take a BubbleSort, QuickSort or any other sorting algorithms and try to sort [8] it will return “\b”. Or [12,10,11] will return “\n\v\f”. Can someone please help me?
I am new with functional programming languages and I can’t understand why in Erlang,
Share
This is due to the fact that Erlang represents strings as lists of numbers. When printing such a list, the Erlang output function will look to see whether your list contains all numbers that correspond to ASCII character values. If so, then it prints your list as a string.
It sounds like your code is working correctly. Try sorting
[12345, 29348, 978]with your existing code to see what happens.See the reference manual section 2.11 String for information about this.