I am using the following code to easily generate a row of images of all eight planets of our Solar System:
Labeled[# // Text, AstronomicalData[#, "Image"]] & /@
AstronomicalData["Planet"] // Row
I like the above code because it is concise and gives nice output. However, if I wanted to do something similar for the moons in our Solar System, I run into the problem that only some moons have images. If I run the following line of code, I get a somewhat sloppy output with Missing Image
errors embedded.
Labeled[# // Text, AstronomicalData[#, "Image"]] & /@
AstronomicalData["PlanetaryMoon"] // Row
I was wondering if there is a simple way to Map
over a list of data conditionally? That is, if an element in a list does not meet a specific condition then skip over it. Note that I'm looking to avoid an explicit loop with an If
construct. I really don't mind using a loop with an If
statement, but I was curious if there was a concise idiom that anyone could shed some light on.