(def songs-data ["Pale Fire""Monument"])
(def songs-meta (with-meta songs-data {:note"I especially like 'Pale Fire'"}))
(meta songs-meta) ; {:note "I especially like 'Pale Fire'"}
Metadata is not dealt with separate from regular data:
Save the following song data to disk, e.g. under /tmp/songs.clj:
{:name"Aces High":band"Iron Maiden":album"Powerslave":year1984}
{:name"Damnation":band"Fates Warning":album"Night on Bröcken":year1984}
{:name"The Apparition":band"Fates Warning":album"Spectre Within":year1985}
{:name"Wasted Years":band"Iron Maiden":album"Somewhere in Time":year1986}
{:name"Giant's Lore":band"Fates Warning":album"Awaken the Guardian":year1986}
{:name"The Ivory Gate of Dreams":band"Fates Warning":album"No Exit":year1988}
{:name"Infinite Dreams":band"Iron Maiden":album"Seventh Son of a Seventh Son":year1988}
{:name"Through Different Eyes":band"Fates Warning":album"Perfect Symmetry":year1989}
{:name"Fates Warning":band"Iron Maiden":album"No Prayer for the Dying":year1990}
{:name"Life in Still Water":band"Fates Warning":album"Parallels":year1991}
{:name"Judas Be My Guide":band"Iron Maiden":album"Fear of the Dark":year1992}
{:name"Pale Fire":band"Fates Warning":album"Inside Out":year1994}
{:name"Monument":band"Fates Warning":album"Inside Out":year1994}
{:name"Lord of the Flies":band"Iron Maiden":album"The X Factor":year1995}
Write a function songs-from-file that expects a path as parameter
and returns a vector of songs.
Hint: Use slurp to read the data. Use clojure.string/split-lines
to separate the string into lines. Use read-string to turn the lines
into data.
Write a function run-pipeline that expects a sequence of songs (as
from the first exercise) and a sequence of functions (as from the
second exercise). The function shall process the given songs using the
given functions to be executed as a pipeline, i.e. one by one
according to its metadata: If a function is of the kind :filter, it
shall be executed as a predicate to filter; if it is of the kind
:mapper, it sh all be executed as a transformer to map.
Hint: Use the meta function to access the metadata of the pipeline
function.