Last active
October 6, 2018 04:29
-
-
Save craftgear/bcf433f72c170c579fb8a1ad2f6c52f8 to your computer and use it in GitHub Desktop.
#SurviveJS 05 LT「forループを越えて」
This file contains hidden or 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 double = x => x * 2; | |
const over5 = x => x > 5; | |
const a = [1, 2, 3].map(double).filter(over5); | |
console.log('********* a', a); | |
import * as R from 'ramda'; | |
const times2Over5 = R.compose( | |
R.tap(console.log), | |
R.filter(over5), | |
R.tap(console.log), | |
R.map(double) | |
); | |
const b = times2Over5([1, 2, 3]); | |
console.log('********* b', b); | |
const c = times2Over5({ a: 1, b: 2, c: 3, str: 'string' }); | |
console.log('********* c', c); | |
// error! | |
// const hoge = { a: 1, b: 2, c: 3 }; | |
// hoge.map(x => x); | |
// error! | |
// const e = times2Over5(null); | |
// console.log('********* e', e); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment