Created
June 22, 2018 20:16
-
-
Save sebabouche/e50460f11d22e0dc646395e8c18fa97a to your computer and use it in GitHub Desktop.
ramda: map, filter, partial, partialRight, curry, __, pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { map, filter, partial, partialRight, curry, __, pipe } from "ramda" | |
const publishedInYear = curry((year, book) => book.year === year) | |
const titlesForYear = curry((year, books) => | |
pipe( | |
filter(publishedInYear(year)), | |
map(book => book.title), | |
)(books), | |
) | |
const books = [ | |
{ year: 2000, title: "OMG" }, | |
{ year: 2000, title: "QBT" }, | |
{ year: 2001, title: "SDF" }, | |
{ year: 2001, title: "SFE" }, | |
{ year: 2002, title: "HHJ" }, | |
] | |
console.log("titlesForYear(books, 2000", titlesForYear(2000, books)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment