Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Array Monad">
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.20.1/ramda.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>List Monad</title>
</head>
<body>
</body>
</html>
 
Array.pure = function(x) {
  return [x];
}
Array.prototype.bind = function(f) {
  return this.reduce((acc, a) => acc.concat(f(a)), [])
};
// range (1, 10) = [1, 2, 3, ..., 10]
function range(from, to) {
  return [for (i of Array(to).keys()) from + i]
}
// note difference between map and bind
console.log(
  [1, 2, 3, 4, 5].map(x => range(1, x))
);
console.log(
  [1, 2, 3, 4, 5].bind(x => range(1, x))
);
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
homampro
0viewers