Sebb
sth like string — Common string operations — Python 3.14.6 documentation?
I really fear erlang’s ~F.P.PadModC (io — OTP 29.0.2 (stdlib 8.0.1))
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
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!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
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
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #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
- #blog-post
- #elixirconf-us
- #elixir-ls
- #ai
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hauleth
What is there to fear? It is almost the same as Python instead of
%you use~. If anything we will get wrapper overio_lib:format/2as it is handy forreport_cbin logger handlers.Sebb
For example I just had to format a CSS compatible hex color. (
#RRGGBB, eg(0,0,255) -> #0000FF)Could not figure that out from the documentation.
Also it is actually two things.
io_lib:formatwhich I do not like (maybe I’m just too stupid, but not all coders geniuses, and Elixir is mostly a very easy language, so I might be spoiled also)kasperkronborg
I actually agree with you @Sebb.
I generally like the Erlang documentation and I no problems in translating that into Elixir, but I had a really hard time with the documentation for
io_lib:formatand the understanding of this. I believe it’s because I’ve got so used to everything else in Elixir is so intuitive and understandable that most times I just need to skim through the documentation to get back into the groove of things. Which I think is super important in a dynamic language where the language server isn’t always there to help you with introspection.al2o3cr
For future readers, here’s the format needed:
Values smaller than zero or larger than 255 will be replaced with
**:Breakdown in detail:
2is the field width. Without it, values less than 16 will only output a single character16is called “precision” in the API, but for theBcontrol sequence it’s the base to use0is the padding character, because we want4to print as04not<space>4Sebb
I admit, with some patience the docs are understandable.
One thing that confused me are the
., but I now understand, that they are only needed when one of P, Pad,or Mod right to it is used, here the dot right to16is wrong, only needed whenPadis used.Interpolation
So what about
I think that would be useful.
al2o3cr
IMO that’s too big of a change - one of the nice things about Elixir is the regularity of the syntax, and that would make
#{}magical in a way that’s not available elsewhere. A more “Elixir-y” solution would be to make the conversion explicit:Some other gotchas that come to mind:
*in the various positions) means more tricky syntax"#{some_calculation():i}"do? “Ignore one thing from the input” makes a lot more sense when the format and the data are fully separated (as in:io)hauleth
That topic gave me an idea for a library. I will try to draft something this weekend.
Sebb
That’s true. But maybe inside a sigil?
Really? Does not seem too hard, but I dont know too much about parsers.
Just take the output and pass it to the formatter?
may raise
I do not understand what you mean.
Yes, that’s not nice in this case. So we would be responsible to call sth like
to_string().RemyXRenard
This is somewhat of a thread necro, and I already posted this in the Livebook category, but if someone comes here looking for some :io_lib.format examples, I put together a Livebook.
Fun with formatting: