我有导演的这部电影集:
([{: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}])
这是3个矢量(导演)和相应电影的列表
如果我这样做:
(doseq [directors-movie movies]
(doseq [movie directors-movie]
(println movie)))
我可以逐个打印所有电影:
#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}
我需要的是将所有这些电影放入Vector。
谢谢, R.
答案 0 :(得分:7)
(reduce into [] l)
或
(into [] cat l)
将会执行(l
是您的输入列表)
答案 1 :(得分:2)
这样做:
(-> movies
flatten
vec)
替代方案是:
(->> movies
(apply concat)
vec)
,并且:
(->> movies
(mapcat identity)
vec)