Pelemay 0.0.6 has been released!
A new feature of this release is to support String.replace.
defmodule M do
require Pelemay
import Pelemaydefpelemay do
def string_replace(subject) do
String.replace(&1, “Fizz”, “Buzz”)
enddef enum_map_string_replace(list) do list |> Enum.map(& String.replace(&1, "Fizz", "Buzz")) end
end
end
This code is 4x faster than original Elixir code.
StringReplaceBench
benchmark name iterations average time
Pelemay String.replace 1000000 1.20 µs/op
Enum String.replace 500000 3.92 µs/op
Flow String.replace 5000 678.27 µs/op
I wrote an article: