Can elixir make optimisations of Enum.count automatically?

Quick question!

If you have code like this
if Enum.count(x) > 1 do .... end

Can elixir optimise the line, and exit the count as soon as more than one element exists?
Is it worth me writing my own function for this? or is there a function that does this instead?
something like Enum.more_than(x, 1)

Thank you!


Enum.count_until can do that.


If you create an issue in Tria optimizing compiler with this feature, I’ll implement it.


Legend! :slight_smile:

p.s, Im read through that repo, honestly insane how good some people are

Ok, didnt think it would to be honest, but you never know with some langs.