How can I delete key from structs in list thank you

[
  %Licensir.License{
    app: :earmark_parser,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :earmark_parser,
      deps: [],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :earmark_parser, "1.4.12",
         "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449",
         [:mix], [], "hexpm",
         "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/earmark_parser",
        dest: "/home/alan/code/elixir-test/cards/deps/earmark_parser",
        hex: "earmark_parser",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 1.4.0",
      scm: Hex.SCM,
      status: {:ok, "1.4.12"},
      system_env: [],
      top_level: false
    },
    file: "Apache 2",
    hex_metadata: ["Apache-2.0"],
    license: "Apache 2.0",
    mix: nil,
    name: "earmark_parser",
    version: "1.4.12"
  },
  %Licensir.License{
    app: :nimble_parsec,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :nimble_parsec,
      deps: [],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :nimble_parsec, "1.1.0",
         "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89",
         [:mix], [], "hexpm",
         "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/nimble_parsec",
        dest: "/home/alan/code/elixir-test/cards/deps/nimble_parsec",
        hex: "nimble_parsec",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 1.1",
      scm: Hex.SCM,
      status: {:ok, "1.1.0"},
      system_env: [],
      top_level: false
    },
    file: nil,
    hex_metadata: ["Apache 2"],
    license: "Apache 2.0",
    mix: nil,
    name: "nimble_parsec",
    version: "1.1.0"
  },
  %Licensir.License{
    app: :makeup,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :makeup,
      deps: [
        %Mix.Dep{
          app: :nimble_parsec,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/makeup/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/nimble_parsec",
            dest: "/home/alan/code/elixir-test/cards/deps/nimble_parsec",
            hex: "nimble_parsec",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 0.5 or ~> 1.0",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        }
      ],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :makeup, "1.0.5",
         "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c",
         [:mix],
         [
           {:nimble_parsec, "~> 0.5 or ~> 1.0",
            [hex: :nimble_parsec, repo: "hexpm", optional: false]}
         ], "hexpm",
         "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup",
        dest: "/home/alan/code/elixir-test/cards/deps/makeup",
        hex: "makeup",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 1.0",
      scm: Hex.SCM,
      status: {:ok, "1.0.5"},
      system_env: [],
      top_level: false
    },
    file: "Unrecognized license file content",
    hex_metadata: ["BSD"],
    license: "Unsure (found: BSD, Unrecognized license file content)",
    mix: nil,
    name: "makeup",
    version: "1.0.5"
  },
  %Licensir.License{
    app: :licensir,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :licensir,
      deps: [],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :licensir, "0.6.2",
         "25cbe2b7cfaf85e20cf0c35bca804265d5171425b51a85e43290565462925cbc",
         [:mix], [], "hexpm",
         "c3c6f18454b99ee2abf669129d14e2cdff6c69a8e39089b5595a19abfb2da3aa"},
        env: :prod,
        repo: "hexpm",
        hex: "licensir",
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/licensir",
        dest: "/home/alan/code/elixir-test/cards/deps/licensir",
        only: :dev,
        runtime: false
      ],
      requirement: "~> 0.6",
      scm: Hex.SCM,
      status: {:ok, "0.6.2"},
      system_env: [],
      top_level: true
    },
    file: "MIT",
    hex_metadata: ["MIT"],
    license: "MIT",
    mix: nil,
    name: "licensir",
    version: "0.6.2"
  },
  %Licensir.License{
    app: :makeup_elixir,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :makeup_elixir,
      deps: [
        %Mix.Dep{
          app: :makeup,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup",
            dest: "/home/alan/code/elixir-test/cards/deps/makeup",
            hex: "makeup",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 1.0",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        },
        %Mix.Dep{
          app: :nimble_parsec,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/nimble_parsec",
            dest: "/home/alan/code/elixir-test/cards/deps/nimble_parsec",
            hex: "nimble_parsec",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 1.1",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        }
      ],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :makeup_elixir, "0.15.1",
         "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd",
         [:mix],
         [
           {:makeup, "~> 1.0",
            [hex: :makeup, repo: "hexpm", optional: false]},
           {:nimble_parsec, "~> 1.1",
            [hex: :nimble_parsec, repo: "hexpm", optional: false]}
         ], "hexpm",
         "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup_elixir",
        dest: "/home/alan/code/elixir-test/cards/deps/makeup_elixir",
        hex: "makeup_elixir",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 0.14",
      scm: Hex.SCM,
      status: {:ok, "0.15.1"},
      system_env: [],
      top_level: false
    },
    file: "Unrecognized license file content",
    hex_metadata: ["BSD"],
    license: "Unsure (found: BSD, Unrecognized license file content)",
    mix: nil,
    name: "makeup_elixir",
    version: "0.15.1"
  },
  %Licensir.License{
    app: :ex_doc,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :ex_doc,
      deps: [
        %Mix.Dep{
          app: :earmark_parser,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/earmark_parser",
            dest: "/home/alan/code/elixir-test/cards/deps/earmark_parser",
            hex: "earmark_parser",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 1.4.0",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        },
        %Mix.Dep{
          app: :makeup_elixir,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup_elixir",
            dest: "/home/alan/code/elixir-test/cards/deps/makeup_elixir",
            hex: "makeup_elixir",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 0.14",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        }
      ],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :ex_doc, "0.23.0",
         "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d",
         [:mix],
         [
           {:earmark_parser, "~> 1.4.0",
            [hex: :earmark_parser, repo: "hexpm", optional: false]},
           {:makeup_elixir, "~> 0.14",
            [hex: :makeup_elixir, repo: "hexpm", optional: false]}
         ], "hexpm",
         "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
        env: :prod,
        repo: "hexpm",
        hex: "ex_doc",
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/ex_doc",
        dest: "/home/alan/code/elixir-test/cards/deps/ex_doc"
      ],
      requirement: "~> 0.12",
      scm: Hex.SCM,
      status: {:ok, "0.23.0"},
      system_env: [],
      top_level: true
    },
    file: "Apache 2",
    hex_metadata: ["Apache-2.0"],
    license: "Apache 2.0",
    mix: nil,
    name: "ex_doc",
    version: "0.23.0"
  }
]
iex(2)> Work.create_deck
[
  %Licensir.License{
    app: :earmark_parser,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :earmark_parser,
      deps: [],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :earmark_parser, "1.4.12",
         "b245e875ec0a311a342320da0551da407d9d2b65d98f7a9597ae078615af3449",
         [:mix], [], "hexpm",
         "711e2cc4d64abb7d566d43f54b78f7dc129308a63bc103fbd88550d2174b3160"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/earmark_parser",
        dest: "/home/alan/code/elixir-test/cards/deps/earmark_parser",
        hex: "earmark_parser",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 1.4.0",
      scm: Hex.SCM,
      status: {:ok, "1.4.12"},
      system_env: [],
      top_level: false
    },
    file: "Apache 2",
    hex_metadata: ["Apache-2.0"],
    license: "Apache 2.0",
    mix: nil,
    name: "earmark_parser",
    version: "1.4.12"
  },
  %Licensir.License{
    app: :nimble_parsec,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :nimble_parsec,
      deps: [],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :nimble_parsec, "1.1.0",
         "3a6fca1550363552e54c216debb6a9e95bd8d32348938e13de5eda962c0d7f89",
         [:mix], [], "hexpm",
         "08eb32d66b706e913ff748f11694b17981c0b04a33ef470e33e11b3d3ac8f54b"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/nimble_parsec",
        dest: "/home/alan/code/elixir-test/cards/deps/nimble_parsec",
        hex: "nimble_parsec",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 1.1",
      scm: Hex.SCM,
      status: {:ok, "1.1.0"},
      system_env: [],
      top_level: false
    },
    file: nil,
    hex_metadata: ["Apache 2"],
    license: "Apache 2.0",
    mix: nil,
    name: "nimble_parsec",
    version: "1.1.0"
  },
  %Licensir.License{
    app: :makeup,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :makeup,
      deps: [
        %Mix.Dep{
          app: :nimble_parsec,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/makeup/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/nimble_parsec",
            dest: "/home/alan/code/elixir-test/cards/deps/nimble_parsec",
            hex: "nimble_parsec",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 0.5 or ~> 1.0",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        }
      ],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :makeup, "1.0.5",
         "d5a830bc42c9800ce07dd97fa94669dfb93d3bf5fcf6ea7a0c67b2e0e4a7f26c",
         [:mix],
         [
           {:nimble_parsec, "~> 0.5 or ~> 1.0",
            [hex: :nimble_parsec, repo: "hexpm", optional: false]}
         ], "hexpm",
         "cfa158c02d3f5c0c665d0af11512fed3fba0144cf1aadee0f2ce17747fba2ca9"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup",
        dest: "/home/alan/code/elixir-test/cards/deps/makeup",
        hex: "makeup",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 1.0",
      scm: Hex.SCM,
      status: {:ok, "1.0.5"},
      system_env: [],
      top_level: false
    },
    file: "Unrecognized license file content",
    hex_metadata: ["BSD"],
    license: "Unsure (found: BSD, Unrecognized license file content)",
    mix: nil,
    name: "makeup",
    version: "1.0.5"
  },
  %Licensir.License{
    app: :licensir,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :licensir,
      deps: [],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :licensir, "0.6.2",
         "25cbe2b7cfaf85e20cf0c35bca804265d5171425b51a85e43290565462925cbc",
         [:mix], [], "hexpm",
         "c3c6f18454b99ee2abf669129d14e2cdff6c69a8e39089b5595a19abfb2da3aa"},
        env: :prod,
        repo: "hexpm",
        hex: "licensir",
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/licensir",
        dest: "/home/alan/code/elixir-test/cards/deps/licensir",
        only: :dev,
        runtime: false
      ],
      requirement: "~> 0.6",
      scm: Hex.SCM,
      status: {:ok, "0.6.2"},
      system_env: [],
      top_level: true
    },
    file: "MIT",
    hex_metadata: ["MIT"],
    license: "MIT",
    mix: nil,
    name: "licensir",
    version: "0.6.2"
  },
  %Licensir.License{
    app: :makeup_elixir,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :makeup_elixir,
      deps: [
        %Mix.Dep{
          app: :makeup,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup",
            dest: "/home/alan/code/elixir-test/cards/deps/makeup",
            hex: "makeup",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 1.0",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        },
        %Mix.Dep{
          app: :nimble_parsec,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/makeup_elixir/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/nimble_parsec",
            dest: "/home/alan/code/elixir-test/cards/deps/nimble_parsec",
            hex: "nimble_parsec",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 1.1",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        }
      ],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :makeup_elixir, "0.15.1",
         "b5888c880d17d1cc3e598f05cdb5b5a91b7b17ac4eaf5f297cb697663a1094dd",
         [:mix],
         [
           {:makeup, "~> 1.0",
            [hex: :makeup, repo: "hexpm", optional: false]},
           {:nimble_parsec, "~> 1.1",
            [hex: :nimble_parsec, repo: "hexpm", optional: false]}
         ], "hexpm",
         "db68c173234b07ab2a07f645a5acdc117b9f99d69ebf521821d89690ae6c6ec8"},
        env: :prod,
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup_elixir",
        dest: "/home/alan/code/elixir-test/cards/deps/makeup_elixir",
        hex: "makeup_elixir",
        repo: "hexpm",
        optional: false
      ],
      requirement: "~> 0.14",
      scm: Hex.SCM,
      status: {:ok, "0.15.1"},
      system_env: [],
      top_level: false
    },
    file: "Unrecognized license file content",
    hex_metadata: ["BSD"],
    license: "Unsure (found: BSD, Unrecognized license file content)",
    mix: nil,
    name: "makeup_elixir",
    version: "0.15.1"
  },
  %Licensir.License{
    app: :ex_doc,
    certainty: 0.0,
    dep: %Mix.Dep{
      app: :ex_doc,
      deps: [
        %Mix.Dep{
          app: :earmark_parser,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/earmark_parser",
            dest: "/home/alan/code/elixir-test/cards/deps/earmark_parser",
            hex: "earmark_parser",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 1.4.0",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        },
        %Mix.Dep{
          app: :makeup_elixir,
          deps: [],
          extra: [],
          from: "/home/alan/code/elixir-test/cards/deps/ex_doc/mix.exs",
          manager: nil,
          opts: [
            env: :prod,
            build: "/home/alan/code/elixir-test/cards/_build/dev/lib/makeup_elixir",
            dest: "/home/alan/code/elixir-test/cards/deps/makeup_elixir",
            hex: "makeup_elixir",
            repo: "hexpm",
            optional: false
          ],
          requirement: "~> 0.14",
          scm: Hex.SCM,
          status: {:ok, nil},
          system_env: [],
          top_level: false
        }
      ],
      extra: [],
      from: "/home/alan/code/elixir-test/cards/mix.exs",
      manager: :mix,
      opts: [
        lock: {:hex, :ex_doc, "0.23.0",
         "a069bc9b0bf8efe323ecde8c0d62afc13d308b1fa3d228b65bca5cf8703a529d",
         [:mix],
         [
           {:earmark_parser, "~> 1.4.0",
            [hex: :earmark_parser, repo: "hexpm", optional: false]},
           {:makeup_elixir, "~> 0.14",
            [hex: :makeup_elixir, repo: "hexpm", optional: false]}
         ], "hexpm",
         "f5e2c4702468b2fd11b10d39416ddadd2fcdd173ba2a0285ebd92c39827a5a16"},
        env: :prod,
        repo: "hexpm",
        hex: "ex_doc",
        build: "/home/alan/code/elixir-test/cards/_build/dev/lib/ex_doc",
        dest: "/home/alan/code/elixir-test/cards/deps/ex_doc"
      ],
      requirement: "~> 0.12",
      scm: Hex.SCM,
      status: {:ok, "0.23.0"},
      system_env: [],
      top_level: true
    },
    file: "Apache 2",
    hex_metadata: ["Apache-2.0"],
    license: "Apache 2.0",
    mix: nil,
    name: "ex_doc",
    version: "0.23.0"
  }
]

Hello and welcome,

Please don’t forget to add code fence ``` around code block to make it more readable.

I made the change…

1 Like

You cannot delete struct keys as it would no longer be struct. You can turn struct into map and then change it.

defmodule Example do
  defstruct [x: 1, y: 2, z: 3]
end

iex> %Example{} |> Map.from_struct() |> Map.delete(:z)
%{x: 1, y: 2}

If you want to do it for every struct in list then use Enum.map/2:

defmodule Example do
  defstruct [x: 1, y: 2, z: 3]
end

iex> list = List.duplicate(%Example{}, 3)
iex> list |> Enum.map(& &1 |> Map.from_struct() |> Map.delete(:z))
[%{x: 1, y: 2}, %{x: 1, y: 2}, %{x: 1, y: 2}]
5 Likes