Skip to content

Instantly share code, notes, and snippets.

@sebabouche
Created June 22, 2018 20:16
Show Gist options
  • Save sebabouche/e50460f11d22e0dc646395e8c18fa97a to your computer and use it in GitHub Desktop.
Save sebabouche/e50460f11d22e0dc646395e8c18fa97a to your computer and use it in GitHub Desktop.
ramda: map, filter, partial, partialRight, curry, __, pipe
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