Search
 
SCRIPT & CODE EXAMPLE
 

ELIXIR

elixir map to new map

users_list = [
  %{id: 1, name: "Alice", role: "user", age: 20},
  %{id: 2, name: "Bob", role: "admin", age: 30},
  %{id: 3, name: "John", role: "editor", age: 40}
]

users = Enum.map(users_list, fn user_struct ->
  Map.take(user_struct, [:id, :name])
end)
# [
#  %{id: 1, name: "Alice"}, 
#  %{id: 2, name: "Bob"}, 
#  %{id: 3, name: "John"}
# ]
Comment

PREVIOUS NEXT
Code Example
Elixir :: ** (Ecto.ConstraintError) constraint error when attempting to insert struct: * id_fkey (foreign_key_constraint) 
Elixir :: elixir enum any 
Elixir :: phoenix ecto preload 
Elixir :: elixir with syntax 
Elixir :: phoenix ecto query bindingess 
Elixir :: elixir pipeline 
Scala :: scala random number 
Scala :: scala split string to list 
Scala :: sum type scala 
Scala :: scala isinstanceof 
Actionscript :: move records from table to another using knex migration 
Actionscript :: mount_osxfuse: /Users/em/mount_dev: Input/output error 
Excel :: google sheets return multiple columns with vlookup 
Excel :: excel and 
Perl :: perl remove all whitespace 
Perl :: comments in perl 
Pascal :: delay() in Pascal 
Powershell :: debloat window 10 
Gdscript :: godot check if in exported version 
Abap :: abap concatenate 
Assembly :: docker cannot stop container 
Assembly :: difference between machine language and assembly language 
Assembly :: tqdm iterate over range 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: remove non letters from a string javascript 
Javascript :: window.reload 
Javascript :: javascript split and trim 
Javascript :: update node.js dependencies 
Javascript :: javascript to detect browser 
Javascript :: how to get element by title js 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =