Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function doubleInteger(i) {
return i*2;
}
function isNumberEven(i) {
return i%2 === 0;
}
function getFileExtension(i) {
if(i.indexOf('.') >= 0) {
var splits = i.split('.');
return splits[splits.length-1];
}
return false;
}
function longestString(i) {
return longestString2(i, '');
}
function longestString2(i, longest) {
if(i.length === 0) return newLongest;
var newLongest = longest;
var car = i[0];
var cdr = i.slice[1];
if(car.length > longest.length && typeof(car) === "string") newLongest = car;
return longestString2(cdr, newLongest);
}
function arraySum(i) {
if(i.length === 0) return 0;
var car = i[0];
var cdr = i.slice(1);
if(typeof(car) === "object") return arraySum(car) + arraySum(cdr);
if(typeof(car) === "number") return car + arraySum(cdr);
return arraySum(cdr);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment