I want to encode this algorithm In Elixir:
var name = generate_name();
while (check_if_exists(name)) {
name = generate_name();
}
I can't encode that the same way in Elixir because there must more idiomatic and functional way. How can I do that then?
generate_name()orcheck_if_exists()be implemented as processing a map/list - say a map/list of possible/existing names? Two ways forward and key lookup in amapelixir-lang.org/getting-started/keywords-and-maps.html or a database query using Ecto hexdocs.pm/ecto/Ecto.Query.html