Reputation: 802
How do I match values through a list? In my case I have a list of colors -
["Black", "Lavender", "Brazen", "Army", "Birch"]
I have this function that creates a collection of the color name and a related URL:
(combine-color-imgurl get-product-images)
=>
[("Black"
"example.com/WWbNhro1n3YfmQTx1q5Piv1j8lZzse6M-25_2a353315-9965-457f-83f8-32af89f3b067.jpeg")
("Lavender"
"example.com/trWCTNYNOfiA8EBX9HZcxVB1Hg8pVtr9-25_403cbe3e-9894-4ad6-9f69-dedcfd7ef77b.jpeg")
("Brazen"
"example.com/COYrBHEsiOgdeOfxsQGcw8XXynsVdpxy-25_af0a9ff9-b988-467e-9b39-c4ae572420e8.jpeg")
("Army"
"example.com/YWKhJXFM0dKhJuRXphCXD4TWstnZRRJm-25_b3a2e43c-3c8c-4abc-83d2-d00d9b3ed594.jpeg")
("Birch"
"example.com/IRsHVjavdFsybvmpT6xjnpKqMtjyjeoZ-25_6321e4ef-5bed-463f-990a-1857151b8a11.jpeg")]
I'm not exactly sure how to get only the URL related to the color.
So the function would be something like
(defn get-url [color]
(some-operation (combine-color-imgurl get-product-images)))
=> URL
Upvotes: 0
Views: 47
Reputation: 802
As mentioned by Juan, the solution was to have combine-color-imgurl
return a map then use
(get (into {} (combine-color-imgurl get-product-images)) color)
to get the URL.
Upvotes: 2