Skip to content

jschomay/learn-you-some-ramda

Repository files navigation

Learn you some ramda.js

Ramda.js is a small and practical library that makes it easy to use functional-style programing in javascript.

Ramda homepage and docs

Why Ramda? What's wrong with underscore/lodash? Ramda makes 2 important FP concepts very natural and practical:

  • currying
  • composing

Why Ramda quick overview and example.

Introduction to benefits and central tools of functional programing.

Learning Ramda with a simple chart-building example

Challenge: graph a clustered bar chart clipped along the y-axis between 0 and 10 for the following collection of raw data:

const data1 = [10, 4, -5, 0, 8, 14];
const data2 = [8, -3, 1, 2, 22, 7];

Given a charting library with the following public api:

drawBarCluster(xIndex, arrayOfClusteredHeights);

Expected output:

Expected chart output

The process

Read through data-functional.js from top to bottom to see the process of manually going from imperative code (see data-imperative.js) to ramda code.

By seeing each manual leap forward, you can gain insight into thinking in a more functional style, and appreciate how ramda makes writing functional javascript more practical.

Once you have gone through that, try applying the same principles and the tools ramda's api provides to the rest of the challenge.

You can add your code to main.js. Run it with npm install and npm start, then open a browser to localhost:8080. See sample.js for my implementation.

About

Lesson and workshop to teach ramda.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published