Elixir Fortaleza Conf 2023 A small language (Ovo2) in Elixir : a graphical stateful environment

How to run a function N times

Ever want to do something N times?

If you come from the Ruby on Rails world (like I did), you might be looking for something like 5.times { do_something }.

This is one way I like to do this:

  • Create a stream with the function you want to run repeatedly with Stream.repeatedly/1.
  • Then, when you want to run that N times, you Enum.take(N)!

Check it out! 👇

https://www.elixirstreams.com/tips/run-elixir-function-n-times