This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var f = function(a){ | |
return a + 1; | |
} | |
var g = function(b){ | |
return - b | |
} | |
function compose(f, g){ | |
return function(a){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var f = function(a){ | |
return a + 1; | |
} | |
var g = function(b){ | |
return - b | |
} | |
function compose(f, g){ | |
return function(a){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nyan = ->(a, b){a + b} | |
curried_nyan = nyan.curry | |
p curried_nyan.(1) # => Proc "->(b){1 + b}" | |
p curried_nyan.(1).(2) #=> 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nyan = ->(a, b){a + b} | |
curried_nyan = nyan.curry | |
fun_list = [1, 2, 3, 4, 5, 6].map(&curried_nyan) # => [->(b){1 + b} , ->(b){2 + b}...] | |
p fun_list.first.(1) #=> 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nyan = ->(a, b){a + b} | |
curried_nyan = nyan.curry | |
p [1, 2, 3, 4, 5, 6].map(&curried_nyan.(4)) # => [5, 6, 7, 8, 9, 10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nyan = ->(a, b){a + b} | |
curried_nyan = nyan.curry | |
p [1, 2, 3, 4, 5, 6].map(&curried_nyan.(4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.first | |
duped = user.dup | |
duped.changes # => {"email"=>["","[email protected]"],"name"=>["","shinpei"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user = User.first | |
user.email = 'nyan' | |
user.changes # => {"email"=>["[email protected]", "[email protected]"]} | |
duped = user.dup | |
duped.name_chanded? # => true | |
duped.changes # => {"email"=>["", "[email protected]"]], "name"=>[""=>"shinpei"]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark' | |
n = 500000 | |
def lm | |
lambda{1}.call | |
end | |
def bg | |
begin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
php -S localhost:8000 |