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

7MASTERS Programação Funcional - Javascript Funcional Com Ramda

7MASTERS Programação Funcional - Javascript Funcional Com Ramda

Ana Luiza Portello

July 25, 2018
Tweet

More Decks by Ana Luiza Portello

Other Decks in Programming

Transcript

  1. • Lists(map, filter, reduce, contains, replace, passAll, crop, flatten, find)

    • Maths(inc, add, mean, sum) • String(split, replace) • Logics(equals, cond, not) • Relation(intersection, clamp, gt, lt) • Functions(curry, pipe, compose, ifElse, etc)
  2. const add = (x, y) => x + y add(1,

    2); // 3 add(1) // Error
  3. const add = x => y => x + y

    add(1, 2); // 3 add(1) // Function
  4. const divideConta = R.pipe( R.sum, // 51 R.mul(1.1), // 56,1

    R.divide(6) // 9,35 ) divideConta(conta)
  5. R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, 12]]]]);

    // [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
  6. R.evolve({ email: R.toLower, phone: R.replace(‘-’, ‘’), })(data) // { //

    name: “Ana” // email: “[email protected]”, // phone: “11 9869983010” // address: ... // }
  7. const createObj = R.applySpec({ counter: R.inc, userData: { phone: R.trim},

    }) createObj(0, “ 98499-1900”) // {1, userData{ phone: “9849919000”}}
  8. • Rambda - github.com/selfrefactor/rambda • Ramda-fantasy - github.com/ramda/ramda-fantasy • Thinking

    Ramda - randycoulman.com/blog/2016/05/24/thinking-in-ramda-getting -started • Ramda - Derek Stavis(Pagar.me talks)