var evenNums = function(ary) {
return ary.filter(function(num) { return num % 2 === 0 });
};
vs
var evenNums = function(ary) {
var evens = [];
ary.filter(function(num) { if (num % 2 === 0) { evens.push(num) }
var evenNums = function(ary) {
return ary.filter(function(num) { return num % 2 === 0 });
};
vs
var evenNums = function(ary) {
var evens = [];
ary.filter(function(num) { if (num % 2 === 0) { evens.push(num) }
def recursive_fib(n) | |
n <= 1 ? n : recursive_fib(n - 1) + recursive_fib(n - 2) | |
end | |
# recursive_fib | |
# the method takes argument n (digit desired of fibonacci sequence) | |
# first checks if n equals either base case (0 and 1), if so, returns n | |
# if not, sum the two previous digits of n; this will result in two recursive actions, of which | |
# will continue until each recursion (and their subsequent recursions) reaches the base cases (0 and 1) | |
# and returns the [total] sum (the nth digit of the sequence) |
class Image | |
attr_accessor :array | |
def initialize(array) | |
@array = array | |
end | |
def blur(distance = 1) | |
distance.times do | |
transform |