Skip to content

Instantly share code, notes, and snippets.

@mrpotatoes
Created May 31, 2022 13:51
Show Gist options
  • Save mrpotatoes/ee20bce6b8572edc4b49da72ae34c77c to your computer and use it in GitHub Desktop.
Save mrpotatoes/ee20bce6b8572edc4b49da72ae34c77c to your computer and use it in GitHub Desktop.
my ramda confusion
console.clear()
const R = require('ramda')
const person = require('../data/lenses.arrays')
// Not correct --------------------------------------------------------
const getThirdFriend_incorrect = R.pipe(
R.lensProp('friends'),
R.lensIndex(2)
)
const result_incorrect = R.view(getThirdFriend_incorrect, person)
// Actually correct ---------------------------------------------------
const getThirdFriend = R.pipe(
R.lensIndex(2),
R.lensProp('friends'),
);
const result = R.view(getThirdFriend, person);
console.log('incorrect', result_incorrect)
console.log('correct', result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment