ub4
The problem with my code is that for x ← list, do: x+5 always returns garbage (e.g., ~c"\a\t\n\f\r"). It seems that all other values work correctly. I have tried this using a MacBook Pro M2 in VSCode and iex. I have tried this multiple times. Below are my tests and results.
iex(1)> list = [2,4,5,7,8]
[2, 4, 5, 7, 8]
iex(2)> for x <- list, do: x+2
[4, 6, 7, 9, 10]
iex(3)> for x <- list, do: x+3
[5, 7, 8, 10, 11]
iex(4)> for x <- list, do: x+4
[6, 8, 9, 11, 12]
iex(5)> for x <- list, do: x+5
~c"\a\t\n\f\r"
iex(6)> for x <- list, do: x+6
[8, 10, 11, 13, 14]
iex(7)> for x <- list, do: x+7
[9, 11, 12, 14, 15]
I’d really appreciate any guidance you can offer. Thanks!
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
code-shoily
FAQ: Why is my list of integers printed as a string? this might address your issue
christhekeele
What you are seeing (the “c” sigil
~c"…") is called a “charlist”. It’s a format used (more in Erlang than Elixir) to encode text: as unicode codepoints in a list.What is happening is that the numbers you are displaying in a list (
[7, 8, 9, 10, 11, 12]) happen to all be printable unicode codepoints. Elixir defaults to displaying these as charlists in case you were intentionally trying to handle unicode data encoded in this format. (The other lists contain numbers that are not printable unicode codepoints, but numbers that represent other non-printable characters like null characters and carriage returns, and so Elixir determines you must not be trying to display the list of numbers as text.)In this instance,
7happens to be printable as the unicode “bell noise” character\a,8is the tab character\t, etc.Of course in Elixir, we normally use binary strings, not charlists, for textual data. If you are confident you won’t be using charlists to describe textual data (which is a safe assumption), you can prevent IEX from trying to display lists of numbers as charlists by creating a file called
.iex.exsin the root of your project (or in your home directory to apply this to all projects) and instructing it to always inspect things that might be charlists as normal lists of numbers, even if they are all printable unicode codepoints:This will ensure your lists of arbitrary numbers are never interpreted (for display purposes) as textual data. Of course, the data is the same under the covers:
[7, 8, 9, 10, 11, 12] = ~c"\a\t\n\f\r"are the same, and evaluate to the same list of numbers. But this will prevent IEX from making the assumption that there might be valuable unicode information in the list worth displaying to the programmer as text.ub4
Thanks! That fixed it. I really appreciate your help!