Last active
June 21, 2017 20:46
-
-
Save rupeshtiwari/e2e93d1b8d964513a03e13ed0d6acf5d to your computer and use it in GitHub Desktop.
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
const one = document.getElementById('one'); | |
const two = document.getElementById('two'); | |
const three = document.getElementById('three'); | |
const f = R.curry((a,b,c)=>{ | |
a.addEventListener(b, (event)=>{ | |
event.target.style.backgroundColor= c; | |
}); | |
}); | |
f(one,'click','purple'); | |
//---------------------------------------- | |
const one = document.getElementById('one'); | |
const two = document.getElementById('two'); | |
const three = document.getElementById('three'); | |
const f = R.curry((a,b,c)=>{ | |
a.addEventListener(b, (event)=>{ | |
event.target.style.backgroundColor= c; | |
}); | |
}); | |
const clickPurple = f(R.__,'click','purple'); | |
clickPurple(one); | |
clickPurple(two); | |
//------------------------------------------- | |
const one = document.getElementById('one'); | |
const two = document.getElementById('two'); | |
const three = document.getElementById('three'); | |
const f = R.curry((a,b,c)=>{ | |
a.addEventListener(b, (event)=>{ | |
event.target.style.backgroundColor= c; | |
}); | |
}); | |
const click = f(R.__, 'click', R.__); | |
click(one, 'green'); | |
click(two, 'orange'); |
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
const teams = [ | |
{name: 'Lions', score: 5 }, | |
{name: 'Tigers', score: 4 }, | |
{name: 'Bears', score: 6 }, | |
{name: 'Monkeys', score: 2 }, | |
] | |
const getTopNames = function () { | |
const sorted = sort((a,b)=>b.score-a.score, teams) | |
const topTeam = head(sorted) | |
return topTeam; | |
} | |
const result = getTopNames(teams) | |
console.log(result); | |
//---------------------------------- | |
const sortByScoreDesc = sort((a,b)=>b.score-a.score) | |
const getName = prop('name') | |
const getTopNames = function () { | |
const sorted = sortByScoreDesc(teams) | |
const topTeam = head(sorted) | |
const topName = getName(topTeam) | |
return topName; | |
} | |
//--------------------------------------------- | |
const sortByScoreDesc = sort((a,b)=>b.score-a.score) | |
const getName = prop('name') | |
const getTopNames = pipe( | |
sortByScoreDesc, | |
R.head, | |
getName | |
) | |
//------------------------------------------------------ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment