#Enum.chunk_every returns strange things

5 messages · Page 1 of 1 (latest)

honest quartz
#

I try to divide my List into chunks of 3 and discard the rest, for example

my_list=[63, 73, 197, 81, 45, 44, 148, 121, 141, 79, 181, 156, 183, 114, 52, 69]

my_list |> Enum.chunk_every(3, 3, :discard)

I expected to return:

Expected: [[63, 73, 197], [148, 121, 141], [79, 181, 156], [183, 114, 52]]
Actual result: [[63, 73, 197], 'Q-,', [148, 121, 141], [79, 181, 156], [183, 114, 52]]

Where does the 'Q-,' Element come from?

winter island
#

IEx thought your data is a charlist AKA an Erlang string because it is a list of printable Unicode codepoints (integers). the rest of the lists are not in printable range so they were not printed that way

#

you can do IEx.configure(inspect: [charlists: :as_lists]), then it will keep them as numbers

#

note that the data is not altered in either case, only the representation (pretty printing by IEx) is different

honest quartz
#

oh I understand, thank you!