iex(1)> List.duplicate(:something, 5) [:something, :something, :something, :something, :something]
:-) Hi there, > > I would like to know your opinion about an `Enum.repeat/2` function. In > test, I notice often that I write: > > Enum.map(1..5, fn(_) -> :something end) > [:something, :something, :something, :something, :something] > > or > > for (_ Enter code here... <- 1..5), do: :something > => [:something, :something, :something, :something, :something] > > As I am not interested in the value of the input, I think a > `Enum.repeat/2` function would be more efficient: > Enum.repeat(5, fn -> :something end) > => [:something, :something, :something, :something, :something] > > > I am aware that `Enum.times/2` is deprecated in the past in favour of > ranges. I want to highlight that in that function, the value was passed to > the function. > > > What is your take? Or perhaps I overlooked a function? > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/948e0a5b-9b38-4608-b687-543d4ba1ad05%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
