In Elixir, how to fix a nested list

Advertisements In Elixir, I have the following list: [ :juridical_person_document, [re_developments: [[properties: [[re_development: [:re_developer]]]]]], :legal_address ] And my desired output would be this: [ :juridical_person_document, re_developments: [properties: [re_development: [:re_developer]]], :legal_address ] In other words, I want to remove the unnecessary square brackets. How can I achieve that? I am aware that this can be achieved… Read More In Elixir, how to fix a nested list

Elixir List of Tuples to List of Strings

Advertisements I want to take [{‘O’, ‘L’}, {‘E’, ‘L’}, {‘O’, ‘H’}, {‘E’, ‘L’}, {‘E’, ‘H’}] and change it to ["OL", "EL", "OH", "EL", "EH"] but I am not seeing how. Help? >Solution : Maybe like this: Enum.map(my_list, fn {a, b} -> List.to_string([a, b]) end)

how to write document for defp function?

Advertisements when adding document to private function by @doc, in vscode compiler gives the warning message. I can’t find @docp for @doc. defp check_subscript!/3 is private, @doc attribute is always discarded for private functions/macros/typesElixir function is as follows: @doc """ check subscript decreasing or increasing """ defp check_subscript!(x, x1, x2) when x > x1 and… Read More how to write document for defp function?

when controller debuging, error "Endpoint.path/1 is undefined (module Endpoint is not available)" appeared

Advertisements When trying to manual rending, the following error message is received (phoenix_view 1.1.2) Phoenix.View.render(PenWeb.LoginView, "show.html") iex(21)> Phoenix.View.render(PenWeb.LoginView, "show.html", message: "Hello from IEx!") %Phoenix.LiveView.Rendered{ dynamic: #Function<0.19280611/1 in PenWeb.LoginView."show.html"/1>, fingerprint: 131643824716591738070856747524267661638, root: false, static: ["<h2>Log in</h2>\n", ""] } iex(22)> Phoenix.View.render_to_string(PenWeb.LoginView, "show.html", message: "Hello from IEx!") ** (UndefinedFunctionError) function Endpoint.path/1 is undefined (module Endpoint is not available)… Read More when controller debuging, error "Endpoint.path/1 is undefined (module Endpoint is not available)" appeared

how to get value from keyword list which key is integer?

Advertisements The list is like [{0,10},{2,20}]. I have get value 10 when provided by key as 0. I haven’t find the suitable function in Enum, List, Keyword module, and have to use erlang module proplists to solve the problem. Is it necessary? inventory_position_list = [{0,10},{2,20}] x = :proplists.get_value(0,inventory_position_list) >Solution : I believe List.keyfind/4 or List.keyfind!/3… Read More how to get value from keyword list which key is integer?