I have this collection of movies by directors:
([{:title "Blade Runner 2049", :genre "Action", :year 2017}
{:title "Gladiator", :genre "Drama", :year 2000}
{:title "Mars", :genre "Adventure", :year 2015}
{:title "American Gangster", :genre "Crime", :year 2007}]
[{:title "The Godfather", :genre "Crime", :year 1972}
{:title "Apocalypse Now", :genre "Drama", :year 1979}
{:title "Jack", :genre "Comedy", :year 1996}]
[{:title "The Wolf", :genre "Comedy", :year 2013}
{:title "GoodFellas", :genre "Crime", :year 1990}
{:title "The Departed", :genre "Drama", :year 2006}
{:title "The Aviator", :genre "Drama", :year 2004}])
which is a list of 3 vectors(Directors) and the corresponding movies
If I do:
(doseq [directors-movie movies]
(doseq [movie directors-movie]
(println movie)))
I can print all movies one by one:
#imdb.movie.Movie{:title Blade Runner 2049, :genre Action, :year 2017}
#imdb.movie.Movie{:title Gladiator, :genre Drama, :year 2000}
#imdb.movie.Movie{:title Mars, :genre Adventure, :year 2015}
#imdb.movie.Movie{:title American Gangster, :genre Crime, :year 2007}
#imdb.movie.Movie{:title The Godfather, :genre Crime, :year 1972}
#imdb.movie.Movie{:title Apocalypse Now, :genre Drama, :year 1979}
#imdb.movie.Movie{:title Jack, :genre Comedy, :year 1996}
#imdb.movie.Movie{:title The Wolf, :genre Comedy, :year 2013}
#imdb.movie.Movie{:title GoodFellas, :genre Crime, :year 1990}
#imdb.movie.Movie{:title The Departed, :genre Drama, :year 2006}
#imdb.movie.Movie{:title The Aviator, :genre Drama, :year 2004}
What I need is to put all this movies into a Vector.
Thanks, R.
(reduce into [] l)
or
(into [] cat l)
will do (where l
is your input list)
This will do it:
(-> movies
flatten
vec)
Alternatives are:
(->> movies
(apply concat)
vec)
, and:
(->> movies
(mapcat identity)
vec)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With