Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ramdaで手軽に関数型言語を始めよう

 Ramdaで手軽に関数型言語を始めよう

初夏のJavaScript祭2016のLTスライドです。

kaidouji85

May 03, 2016
Tweet

More Decks by kaidouji85

Other Decks in Technology

Transcript

  1. forΛ࢖ͬͨ΍Γํ let postData = []; for (let i in todo)

    { if(todo[i].isChanged) { postData.push(convertData(todo[i])); } }
  2. RamdaΛ࢖ͬͯಉ͡ॲཧΛॻ͘ let chanegedList = R.filter(data=>data.isChanged, todo); let postData = R.map(convertData,

    chanegedList); ωετ͕ਂ͘ͳͯ͘γϯϓϧʹ ͔͠΋ɺม਺ͷ஋͸୅ೖ͔ͯ͠Β
 มΘͬͯͳ͍
  3. ίʔυͱͷରԠ let chanegedList = R.filter(data=>data.isChanged, todo); let postData = R.map(convertData,

    chanegedList); ؔ਺ͷϑΥʔϚοτ͸ҎԼͷ௨Γ ୈҰҾ਺ɿɹ഑ྻཁૉͷ஋ ໭Γ஋ɹɿɹboolean(trueͰ࢒͢)
  4. ίʔυͱͷରԠ let chanegedList = R.filter(data=>data.isChanged, todo); let postData = R.map(convertData,

    chanegedList); ͜ͷྫͰ͸isChanged͕trueͳΒ มߋ͞Εͨͱݟͳ͍ͯ͠Δ ɹˣ มߋ͞Εͨཁૉ͚ͩΛ࢒͢ͱ͍͏ҙຯʹͳΔ
  5. ίʔυͱͷରԠ let chanegedList = R.filter(data=>data.isChanged, todo); let postData = R.map(convertData,

    chanegedList); ؔ਺ͷϑΥʔϚοτ͸ҎԼͷ௨Γ ୈҰҾ਺ɿɹ഑ྻཁૉͷ஋ ໭Γ஋ɹɿɹม׵ޙͷσʔλ
  6. ίʔυͱͷରԠ let chanegedList = R.filter(data=>data.isChanged, todo); let postData = R.map(convertData,

    chanegedList); ͜ͷྫͰ͸convertDataͰ σʔλม׵͢ΔͷͰɺ ͜ΕΛͦͷ··ࢦఆ͢Δ
  7. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); });
  8. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); R.pipeͰෳ਺ͷॲཧΛܨ͔͚͛ͯ·͢
  9. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); ͜͜ʹ࠷ॳͷॲཧʹ౉͢Ҿ਺Λࢦఆ
  10. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); ࠓճ͸TODOຊମͱ ΤϥʔνΣοΫ݁Ռ
  11. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); TODOຊମͱΤϥʔνΣοΫ݁ՌΛ߹ମ
  12. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); R.zipͷ݁Ռ͕͍ͭ͜ͷॲཧର৅ʹͳΔ
  13. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); item[0] : todoຊମ item[1] : ΤϥʔνΣοΫ݁Ռ
  14. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); ͜ͷ৚݅͸Τϥʔ͕͋Δ Ϩίʔυ͚ͩΛ࢒͢ͱ͍͏ҙຯ
  15. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); ΍ͬͺΓR.filterͷ݁Ռ͕ೖྗʹͳΔ
  16. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); ͜͜ͰΤϥʔσʔλʹม׵͢Δ
  17. ίʔυͰॻ͘ͱ͜͏ͳΓ·͢ let promiseList = 
 R.map(todo => isError(todo), todos); Promise.all(promiseList).then(resps

    => { let errorData = R.pipe( R.zip, R.filter(item => item[1].isError), R.map(item => getErrorData(item[0].id)) )(todos, resps); }); Τϥʔσʔλͷ഑ྻ͕֨ೲ͞ΕΔ