Skip to content

Instantly share code, notes, and snippets.

View vetri02's full-sized avatar
🎯
Focusing

Vetrichelvan Jeyapalpandy vetri02

🎯
Focusing
View GitHub Profile
@vetri02
vetri02 / generate
Created August 7, 2011 11:33
Define a function named generate that takes one argument, a function f. It should return an array that consists of the function f and another function that doubles its input.
var generate = function (f) {
var double = function(x) {
return x * 2;
};
return [f, double];
};
var t = function() {return true;};
@vetri02
vetri02 / applyTest
Created August 5, 2011 19:37
Define a function named applyTest that takes two arguments, a function f and an input x. Your function should return a list that contains x, the function f on the input x, and the function f on the input 0.
var addOn = function(x){
return x+1;
};
var applyTest = function (f, x) {
return [x, (f(x)), (f(0))];
};
var y = applyTest(addOn, 1);
@vetri02
vetri02 / splitWordNumero
Created July 27, 2011 10:44
Adds number to each word in a sentence
function splitWordNumero(bar){
var foo = bar;
//var foo = "The quick brown fox jumps over the lazy dog";
var temp = [];
var res = [];
temp = foo.split(' ');
var j = temp.length;
console.log(j);