(CompileError) cannot invoke remote function map.asset/0 inside a match

defmodule Ticker do

   def get_trades do

      case HTTPoison.get("https://api.wavesplatform.com/v0/pairs") do
         {:ok, _} ->
            results = HTTPoison.get!("https://api.wavesplatform.com/v0/pairs")

            %{data: items} = Poison.decode!(results.body, keys: :atoms)
			
            market_snapshot = Enum.map(items, fn item ->
  	       %{
    		asset: item.amountAsset,
    		priced_in: item.priceAsset,
    		last: get_in(item, [:data, :lastPrice]),					
    		volume: get_in(item, [:data, :volumeWaves])
  		}
		end)

            filtered_results = Enum.filter(market_snapshot, fn map -> map.asset = "WAVES" end)
			
            IO.inspect(filtered_results, limit: :infinity)				
							
         {:error, %Elixir.HTTPoison.Error{reason: reason}} ->
 			
	   IO.inspect reason			
						
      end
   end
end

iex(1)> recompile

== Compilation error in file lib/Ticker.ex ==
** (CompileError) lib/Ticker.ex:38: cannot invoke remote function map.asset/0 inside a match

How do I resolve this?

Thanks for your input! :slight_smile:

You can not assign to a field in a map like this, you need to use Map.put/2 or one of the update functions, depending on what you actually want to achieve.

Also please use the formatter before pasting code snippets. This example is hard to follow, as the clause heads and bodies in the case are similarly indented.

3 Likes
iex(1)> Ticker.get_trades
[
  %{
    asset: "EEazYfNWspbhD1viq9S7zUWJ74owa27MhKUk9eRi1oU1",
    last: 58974300,
    priced_in: "AbunLGErT5ctzVN8MVjb4Ad9YgjpubB8Hqb17VxzfAck",
    volume: 290883.535905132
  },
  %{
    asset: "WAVES",
    last: 1.4883,
    priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    volume: 272161.53013378
  },
  %{
    asset: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
    last: 1.026777,
    priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    volume: 267335.321231625 
  },
  %{
    asset: "WAVES",
    last: 1.38e-4,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 236059.38686776
  },
  %{
    asset: "6UfBupFwFnWTrnFDWiR73LQjPxRY38CgZ6Bu4m4SySQY",
    last: 5.03,
    priced_in: "WAVES",
    volume: 214114.7735372
  },
  %{
    asset: "5b3UGNZXX5srkHUQWnEWEiaVtnNWmg5aLo5uZMdjWupH",
    last: 146.69,
    priced_in: "WAVES",
    volume: 191358.551550345
  },
  %{
    asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    last: 189.52,
    priced_in: "WAVES",
    volume: 156159.337213428
  },
  %{
    asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    last: 0.02616616,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 65263.8177689932
  },
  %{
    asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    last: 10695.6739,
    priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    volume: 59402.8014617737
  },
  %{
    asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
    last: 56.72761419,
    priced_in: "WAVES",
    volume: 38266.3868093697
  },
  %{
    asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    last: 282.136349,
    priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    volume: 29868.8925105484
  },
  %{
    asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
    last: 0.00911123,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 25591.7075428954
  },
  %{
    asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
    last: 0.0078765,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 15049.937510415
  },
  %{
    asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
    last: 0.054788,
    priced_in: "WAVES",
    volume: 14850.1302481875
  },
  %{
    asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
    last: 5300,
    priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi",
    volume: 7909.88150035716
  },
  %{
    asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
    last: 4.577e-5,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 5984.56639334164
  },
  %{
    asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
    last: 0.465,
    priced_in: "WAVES",
    volume: 5936.82883114269
  },
  %{
    asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
    last: 6.5e-5,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 5484.70272200052
  },
  %{
    asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
    last: 92.11504108,
    priced_in: "WAVES",
    volume: 5366.10355583244
  },
  %{
    asset: "WAVES",
    last: 1.95,
    priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
    volume: 5111.1273781
  },
  %{
    asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
    last: 0.35377056,
    priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    volume: 4533.59302949823
  },
  %{
    asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
    last: 0.012895,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 4317.43148633982
  },
  %{
    asset: "4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC",
    last: 1495.8897,
    priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi",
    volume: 3589.60637614465
  },
  %{
    asset: "62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH",
    last: 0.0347934,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 3424.5597546161
  },
  %{
    asset: "51LxAtwBXapvvTFSbbh4nLyWFxH6x8ocfNvrXxbTChze",
    last: 0.0004,
    priced_in: "WAVES",
    volume: 3401.01432804662
  },
  %{
    asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
    last: 0.04800003,
    priced_in: "WAVES",
    volume: 3068.9322422338
  },
  %{
    asset: "HXtwvrpL8qiYCGC2D6WdiWgqQ5qSyQRQWmo9zDJk32ki",
    last: 0.0042,
    priced_in: "WAVES",
    volume: 3000.97783280432
  },
  %{
    asset: "3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2",
    last: 0.29000002,
    priced_in: "WAVES",
    volume: 2163.280406054
  },
  %{
    asset: "45aH8AsLe1CgcSmPVek7J3XoZW7n3fnW5Xtw4ohRD2yd",
    last: 2.0e-7,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 2032.72060453679
  },
  %{
    asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
    last: 0.30030104,
    priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    volume: 1841.32377056299
  },
  %{
    asset: "7FzrHF1pueRFrPEupz6oiVGTUZqe8epvC7ggWUx8n1bd",
    last: 0.042001,
    priced_in: "WAVES",
    volume: 1761.90980903888
  },
  %{
    asset: "8Yw4QmskrQauQeNjgh2fTQ4swmkNm85GTQzdHEf6QdUU",
    last: 0.00200476,
    priced_in: "WAVES",
    volume: 1630.82147838235
  },
  %{
    asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    last: 364,
    priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
    volume: 1309.56700880434
  },
  %{
    asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    last: 14100,
    priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
    volume: 1309.17654651792
  },
  %{
    asset: "8ofu3VpEaVCFjRqLLqzTMNs5URKUUQMrPp3k6oFmiCc6",
    last: 0.0058002,
    priced_in: "WAVES",
    volume: 1295.83829520094
  }, 
  %{
    asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
    last: 65.4,
    priced_in: "WAVES",
    volume: 1239.37264031842
  },
  %{
    asset: "WAVES",
    last: 1.81,
    priced_in: "Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU",
    volume: 1239.10263635
  },
  %{
    asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
    last: 7.2e-6,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 1167.84705759755
  },
  %{
    asset: "WAVES",
    last: 1.425,
    priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
    volume: 1159.37379992 
  },
  %{
    asset: "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa",
    last: 50.5959813,
    priced_in: "WAVES",
    volume: 1058.74421770109
  },
  %{
    asset: "knZe9t5sZRqe9khJjWQXKnScaN4WEyY4zM1mCmvvuUB",
    last: 9.0e-7,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 1055.05106999054
  },
  %{
    asset: "7FzrHF1pueRFrPEupz6oiVGTUZqe8epvC7ggWUx8n1bd",
    last: 3658.0855,
    priced_in: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi",
    volume: 775.865635489827
  },
  %{
    asset: "B3uGHFRpSUuGEDWjqB9LWWxafQj8VTvpMucEyoxzws5H",
    last: 0.50865248,
    priced_in: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    volume: 733.640715333541
  },
  %{
    asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
    last: 0.32945131,
    priced_in: "WAVES",
    volume: 627.233340676825
  },
  %{
    asset: "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy",
    last: 0.04552209,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 510.549014147892
  },
  %{
    asset: "4SvrfTcELe39nd28sa64mVEifH5DXpCFemZcu3yWkhqi",
    last: 1.111e-5,
    priced_in: "WAVES",
    volume: 480.167591562316
  },
  %{
    asset: "62LyMjcr2DtiyF5yVXFhoQ2q414VPPJXjsNYp72SuDCH",
    last: 243.02220483,
    priced_in: "WAVES",
    volume: 445.373080477134
  },
  %{
    asset: "975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF",
    last: 0.75,
    priced_in: "WAVES",
    volume: 443.25
  },
  %{
    asset: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    last: 1.26,
    priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
    volume: 414.707011989255
  },
  %{
    asset: "975akZBfnMj513U7MZaHKzQrmsEx5aE3wdWKTrHBhbjF",
    last: 0.9,
    priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    volume: 403.985950288131
  },
  %{
    asset: "3f2XzwnKvnjXp45G3PBcKGze9L6AXasKae7UyiW7AJRV",
    last: 0.008576,
    priced_in: "WAVES",
    volume: 368.93979609
  },
  %{
    asset: "zMFqXuoyrn5w17PFurTqxB7GsS71fp9dfk6XFwxbPCy",
    last: 315.85746782,
    priced_in: "WAVES",
    volume: 363.180818931581
  },
  %{
    asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
    last: 0.092,
    priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
    volume: 348.087211585124
  },
  %{
    asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
    last: 0.675,
    priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
    volume: 327.859967474626
  },
  %{
    asset: "AuJhMZKfiBTwWx46svSnaXJS2cxun7iLnDB2ZAV4FmTF",
    last: 0.2644,
    priced_in: "WAVES",
    volume: 325.212
  },
  %{
    asset: "GSFvcF6ycBfXwPJLLKMExRsHWnvVdZQFHtGiYu4A2kZP",
    last: 12,
    priced_in: "5f1txDysSx2fVDjgXMdNpuprpdgXKjoHPtebL3SrMGzE",
    volume: 305.64
  },
  %{
    asset: "6mRmui8aKUKgDQAQd6TroLCVhKUSNZnt91zR25RGz3SQ",
    last: 0.025,
    priced_in: "WAVES", 
    volume: 299.46625
  },
  %{
    asset: "EbLVSrAi6vS3AkLwBinzZCvAXP2yYiFJEzj1MBVHcwZ5",
    last: 4.25e-6,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 293.210387867622
  },
  %{
    asset: "9qft6gmof8WLhAYyjtHdJhoMJepehXGqtSGex6GxwsA",
    last: 1,
    priced_in: "WAVES",
    volume: 269.00000006
  },
  %{
    asset: "BrjUWjndUanm5VsJkbUip8VRYy6LWJePtxya3FNv4TQa",
    last: 0.00710525,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 252.570952949414
  },
  %{
    asset: "3EidcQ3rEqKayWPsAy1vtQLtdptrXLnGUWYrS56xAGZt",
    last: 1.7e-7,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 239.761232595023
  },
  %{
    asset: "725Yv9oceWsB4GsYwyy4A52kEwyVrL5avubkeChSnL46",
    last: 1,
    priced_in: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
    volume: 239.1635076624
  },
  %{
    asset: "5ZPuAVxAwYvptbCgSVKdTzeud9dhbZ7vvxHVnZUoxf4h",
    last: 1.41500001,
    priced_in: "WAVES",
    volume: 223.535344826024
  },
  %{
    asset: "81HnQ1PWViWUiv39NGkPjbfDehW1edjeJe6XxVhw1TPZ",
    last: 0.015,
    priced_in: "WAVES",
    volume: 211.21125599
  },
  %{
    asset: "8CtML7Frx17jMGRKyMjTEfP8oZPSNH7U87Dcb3XM5PLK",
    last: 9.9e-7,
    priced_in: "WAVES",
    volume: 200.59929351
  },
  %{
    asset: "HKJK3zswXJLbsgJ3pQNiYVNu6svy4SM9zucB8YEJFXqt",
    last: 3.7001e-4,
    priced_in: "WAVES",
    volume: 199.42864067029
  },
  %{
    asset: "6MzCFtn8YfKBNtJnqZJ19Vy8LP9Nu1KK8x5v3CcSKYtx",
    last: 1.1968e-4,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 186.881088053684
  },
  %{
    asset: "AxAmJaro7BJ4KasYiZhw7HkjwgYtt2nekPuF2CN9LMym",
    last: 0.01100003,
    priced_in: "WAVES",
    volume: 186.143290030418
  },
  %{
    asset: "EgdXZCDja5H54dQqvY1GbJEjJ4TzpNtBsj45m1UmQFa2",
    last: 0.00650945,
    priced_in: "WAVES",
    volume: 153.51723687561
  },
  %{
    asset: "bPWkA3MNyEr1TuDchWgdpqJZhGhfPXj7dJdr3qiW2kD",
    last: 0.0025,
    priced_in: "WAVES",
    volume: 153.312611730038
  },
  %{
    asset: "6VywEHj8MMp7x25cxfK3J8UTEPNePwo5U8vrKagLjKDb",
    last: 3.35,
    priced_in: "WAVES",
    volume: 135.423024695
  },
  %{
    asset: "6gr93FQ7Jrein3QoNQfCyRKCTxbYPx2nYxBhaXbgwpAt",
    last: 0.00275997,
    priced_in: "WAVES",
    volume: 100.69040861
  },
  %{
    asset: "8ofu3VpEaVCFjRqLLqzTMNs5URKUUQMrPp3k6oFmiCc6",
    last: 4.7e-7,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 97.085907110684
  },
  %{
    asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
    last: 109.69,
    priced_in: "Ft8X1v1LTa1ABafufpaCWyVj8KkaxUWE6xBhW6sNFJck",
    volume: 82.8792370144207 
  },
  %{
    asset: "G5x5hAnGR76FiJnPhLy2nzT5x9jiQvxbfAAUyeuZqarY",
    last: 1,
    priced_in: "WAVES",
    volume: 79
  },
  %{
    asset: "ETLzrCpBqTrpyuMGdiVLBPZnUoKwte88oVdJjoFi5R2h",
    last: 0.058572,
    priced_in: "WAVES",
    volume: 77.3644157106329
  },
  %{
    asset: "WAVES",
    last: 8.75,
    priced_in: "2mX5DzVKWrAJw8iwdJnV2qtoeVG9h5nTDpTqC1wb1WEN",
    volume: 59.65085433
  },
  %{
    asset: "4vPcbA5yiwpWBVPALPGXus6fNdGEuYTpe4hAeSxM9Kj4",
    last: 2.26e-6,
    priced_in: "WAVES",
    volume: 55.4407563600002
  },
  %{
    asset: "8kGUk1XSG11ac6x2MRbdfjNNjBZYWBQb51fVjRswtVE5",
    last: 0.0033,
    priced_in: "WAVES",
    volume: 54.4873741501152
  },
  %{
    asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    last: 10105,
    priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
    volume: 53.7749365207536
  },
  %{
    asset: "6Ek49jWsUhUmX6SQ8yafqsjF9GT7e3sgqsv7P98yZSvX",
    last: 0.0024,
    priced_in: "WAVES",
    volume: 50.4849996
  },
  %{
    asset: "7HHA2jJwdci3kGc9AVQTbDYtZVhZ49zxXRzhq6sNysSL",
    last: 0.004,
    priced_in: "WAVES",
    volume: 41.25678340782
  },
  %{
    asset: "AbunLGErT5ctzVN8MVjb4Ad9YgjpubB8Hqb17VxzfAck",
    last: 7.1e-5,
    priced_in: "WAVES",
    volume: 41.14942935
  },
  %{
    asset: "HKJK3zswXJLbsgJ3pQNiYVNu6svy4SM9zucB8YEJFXqt",
    last: 6.0e-8,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 40.0744936139595
  },
  %{
    asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
    last: 235,
    priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
    volume: 37.5786024771519
  },
  %{
    asset: "2vH9X6VF97Y4STX2akLwpk1Trn9v9gKdiXUsmU4tCSUG",
    last: 0.005,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 34.151720581833
  },
  %{
    asset: "2eumLdbNPFKqCPTHD6XR7JVu5ejFWggqVTsxdww8Kaq1",
    last: 2.08e-4,
    priced_in: "WAVES",
    volume: 33.64909448
  },
  %{
    asset: "2fiCMUZgBZHs7DtwjyTET8gyToNNX1X5r8zUaouqoztQ",
    last: 0.0006,
    priced_in: "WAVES",
    volume: 33.4813343300079
  },
  %{
    asset: "EZFN36KbtnZTS5TTfDETfcEcjWxU1QguBS9drBRUpDwh",
    last: 1.87e-6,
    priced_in: "WAVES",
    volume: 33.09200003
  },
  %{
    asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    last: 12416.37,
    priced_in: "Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU",
    volume: 32.904111524195
  },
  %{
    asset: "ENHe5dJQtsAcx1zpkXY2EJtjRZPsLocvL3G9JdUfd1Mh",
    last: 0.005,
    priced_in: "WAVES",
    volume: 32.54863332286
  },
  %{
    asset: "FLbGXzrpqkvucZqsHDcNxePTkh2ChmEi4GdBfDRRJVof",
    last: 1.5e-5,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 32.3381346580586
  },
  %{
    asset: "DCveqdzoQG1h6ED28UsdHaegweRx9RMcPxLH2tzpTbCG",
    last: 1.6e-4,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 30.3151987670327
  },
  %{
    asset: "HanPjNrWbmdSBUZYdpuZ6scUXX552QABDrxD4ZKqKJdt",
    last: 11,
    priced_in: "WAVES",
    volume: 29.636
  },
  %{
    asset: "4uK8i4ThRGbehENwa6MxyLtxAjAo1Rj9fduborGExarC",
    last: 0.00751999,
    priced_in: "WAVES",
    volume: 29.5939577103
  },
  %{
    asset: "BngDvQD3VUs9MKgf1cdaRdcXqrrVK8oADzHebJo46h8j",
    last: 1.0e-8,
    priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
    volume: 27.1930633861546
  },
  %{
    asset: "FhsFXnMnZYk2nFQGfcd9rCmDaKYYxqhmDrExUTtDYAtC",
    last: 249.99,
    priced_in: "WAVES",
    volume: 26.8228646208
  },
  %{
    asset: "8LjKWGxXsiLpMziWanFn117e97gNXShD1zwSLCGpSPfb",
    last: 0.02200002,
    priced_in: "WAVES",
    volume: 23.8902496508134
  },
  %{
    asset: "BngDvQD3VUs9MKgf1cdaRdcXqrrVK8oADzHebJo46h8j",
    last: 4.935e-5,
    priced_in: "WAVES",
    volume: 23.0994412700025
  },
  %{
    asset: "5dJj4Hn9t2Ve3tRpNGirUHy4yBK6qdJRAJYV21yPPuGz",
    last: 10.0034079,
    priced_in: "3941Ksn1yygCxWCSNwrQj3K7iqYWmuU46mUwGjdAbrPP",
    volume: 22.0379013366286
  }
]

What I’m trying to do is filter this array of maps such that it excludes a specific asset or group of assets.

As an aside, volume_greater_than_500 = Enum.filter(market_snapshot, fn map -> map.volume >= 500 end) filters out all results whose volume is less than 500. (It’s unclear to me why that works but filtered_results = Enum.filter(market_snapshot, fn map -> map.asset = "WAVES" end) fails.)

So, how would I go about filtering this array of maps based on a specific asset or list of assets?

(The OP has been edited to correct indentations. Thanks for the recommendation and let me know if there’s anything else I can do to enhance readability.)

There’s the core of the issue. The single equals sign (=) is a pattern match operator. What you want here is the equality comparison operator (==). Use this:

filtered_results = Enum.filter(market_snapshot, fn map -> map.asset == "WAVES" end)

3 Likes

That did it! Thanks bud :slight_smile: