Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
</body>
</html>
 
function sequence(startCount, newCount) {
  
  var currentCount = startCount;
  
  return function counter() {
      currentCount += newCount;
      return currentCount;
  };
}
function take(gen, x) {
  
  var mas = [];
  
  for (var i = 0; i < x; i++) {
    mas.push(gen());
  }
  return mas;
}
var square = function(number) {
  return number * number;
};
var counter = sequence(1, 3);
//console.log(counter());
//console.log(counter());
//var gen = take(counter, 5);
//console.log(gen);
//console.log(gen.map(square));
function fmap(square, counter) {
  return function () {
    var res = square(counter());
    return res;
  };
}
var squareCounter = fmap(square, counter);
console.log(squareCounter());
console.log(squareCounter());
Output

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

Dismiss x
public
Bin info
anonymouspro
0viewers