Maxximiliann
Given:
market_data =
[
%{
asset: "3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2",
last_price: 0.1249534,
priced_in: "WAVES",
volume: 13793.6013752778
},
%{
asset: "3QvxP6YFBKpWJSMAfYtL8Niv8KmmKsnpb9uQwQpg8QN2",
last_price: 1.626e-5,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 10311.7855749146
},
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last_price: 189.658785,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 52373.8805236538
},
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last_price: 186.06,
priced_in: "WAVES",
volume: 24023.1442492862
},
%{
asset: "474jTeYx2r2Va35794tCScAXWJG9hU2HcgxzMowaZUnu",
last_price: 0.02497085,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 8690.02335386836
},
%{
asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
last_price: 0.08150997,
priced_in: "WAVES",
volume: 40979.8114711376
},
%{
asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
last_price: 1.097e-5,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 252.945468613465
},
%{
asset: "4LHHvYGNKJUg5hj65aGD5vgScvCBmLpdRFtjokvCjSL8",
last_price: 0.08329,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 201.247929171753
},
%{
asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
last_price: 0.00808268,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 3248.6225669422
},
%{
asset: "5WvPKSJXzVE2orvbkJ8wsQmmQKqTv9sGBPksV4adViw3",
last_price: 60.20503371,
priced_in: "WAVES",
volume: 516.180493091221
},
%{
asset: "7Z5peMVTuyEesJcYn7B6DDtV8oqKAFueBA52vPuf59rh",
last_price: 0.91104345,
priced_in: "WAVES",
volume: 26300.1502283905
},
%{
asset: "7Z5peMVTuyEesJcYn7B6DDtV8oqKAFueBA52vPuf59rh",
last_price: 1.2554e-4,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 577.404317777729
},
%{
asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
last_price: 7532.54,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 163617.091159899
},
%{
asset: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
last_price: 8250,
priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
volume: 1489.58529413729
},
%{
asset: "Bwn3tDxj1rqqFGsnEy7Z829aj8Gs2UVQA7yktaJ6auHN",
last_price: 7.1e-7,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 1259.50422417225
},
%{
asset: "Bwn3tDxj1rqqFGsnEy7Z829aj8Gs2UVQA7yktaJ6auHN",
last_price: 0.00430558,
priced_in: "WAVES",
volume: 290.292294688471
},
%{
asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
last_price: 300000000005,
priced_in: "7b4tRbsy8zNDW35gW9DETdRU5yaNoFGm2SvmwRuCns3f",
volume: 447641.500005591
},
%{
asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
last_price: 0.05229596,
priced_in: "WAVES",
volume: 14287.8709376739
},
%{
asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
last_price: 0.05294568,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 13348.2393706553
},
%{
asset: "DHgwrRvVyqJsepd32YbBqUeDH4GJ1N984X8QoekjgH8J",
last_price: 7.94e-6,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 10824.4211299108
},
%{
asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
last_price: 7.9e-5,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 1666.02995108187
},
%{
asset: "EYz8Zvs62D4d7F5ZgXHCWuzuFaZg63FYnfVQrTWQoLSK",
last_price: 0.57,
priced_in: "WAVES",
volume: 1582.6257
},
%{
asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
last_price: 0.00594059,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 4020.64881215575
},
%{
asset: "HZk1mbfuJpmxU1Fs4AX5MWLVYtctsNcg6e2C6VKqK8zk",
last_price: 43.9669216,
priced_in: "WAVES",
volume: 2384.30279291976
},
%{
asset: "WAVES",
last_price: 1.010899,
priced_in: "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p",
volume: 383661.118208469
},
%{
asset: "WAVES",
last_price: 1.3345e-4,
priced_in: "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS",
volume: 51539.1607843401
},
%{
asset: "WAVES",
last_price: 1.0467,
priced_in: "34N9YcEETLWn93qYQ64EsP1x89tSruJU44RrEMSXXEPJ",
volume: 705.83415129
}
]
Code:
def conversions do
market_data
|> Enum.map(fn map -> if Enum.member?(map.priced_in, "8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJS") do
%{
asset: map.asset,
btc_price: map.last_price
}
else
%{
asset: map.asset,
price: map.last_price,
priced_in: map.priced_in,
asset_to_btc_rate: asset_to_btc_rate(map.priced_in),
btc_price: map.last_price * asset_to_btc_rate(map.priced_in)
}
end
end)
end
Error: ** (Protocol.UndefinedError) protocol Enumerable not implemented for "WAVES" of type BitString. This protocol is implemented for the following type(s): Ecto.Adapters.SQL.Stream, Postgrex.Stream, DBConnection.PrepareStream, DBConnection.Stream, HashSet, Map, Function, List, File.Stream, Date.Range, Range, HashDict, MapSet, Stream, IO.Stream, GenEvent.Stream
What’s going on here and how do I resolve this issue? Thanks for your patient help! ![]()
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Marcus
Hello,
you are mapping over a list of maps. Therefore you get a
mapandmap.prieced_inis a binary and this you give toEnum.member?, butEnum.member?needs anenumerablenot abinary. The first data, in this case, is"WAVES"and for thisprotocol Enumerable not implemented ...Maxximiliann
Thank you for clarifying
Here’s a workaround I’ve attempted:
How can I make this work? Thanks again!
andreolvr
The compile error is happening because this is not the correct syntax for
case, take a look at https://elixir-lang.org/getting-started/case-cond-and-if.html. Another problem in this logic is that the third clause (_) will never be reached, the value is equals8LQW8f7P5d5PZM7GtZEBgaqRPGSzS3DfPuiXrURJ4AJSor not. There is no third option. Maybe you are looking for anif/elseinstead of acase?Maxximiliann
Thanks for your input.
Yields:
How do I address this
nilcase without acasestatement?Marcus
Maybe, you needs …
Maxximiliann
That helped. Thank you so very much!