apply(&my_proc)
click to toggle source
def apply(&my_proc)
my_proc or raise ArgumentError, 'a block argument is required'
lambda { |list| my_proc.call(*list) }
end
array()
click to toggle source
def array
lambda { |*list| list }
end
call(obj, &my_proc)
click to toggle source
def call(obj, &my_proc)
my_proc or raise ArgumentError, 'a block argument is required'
obj.instance_eval(&my_proc)
end
const(konst = nil, &my_proc)
click to toggle source
def const(konst = nil, &my_proc)
konst ||= my_proc.call
lambda { |*_| konst }
end
first()
click to toggle source
def first
lambda { |*list| list.first }
end
from(&block)
click to toggle source
def from(&block)
my_method, binding = block.call, block.binding
my_self = eval 'self', binding
lambda { |*list| my_self.__send__(my_method, *list) }
end
id1()
click to toggle source
def id1
lambda { |obj| obj }
end
last()
click to toggle source
def last
lambda { |*list| list.last }
end
map_apply(my_method, *args, &my_proc)
click to toggle source
def map_apply(my_method, *args, &my_proc)
my_proc or raise ArgumentError, 'a block argument is required'
lambda { |x, y| my_proc.call(x, y.__send__(my_method, *args)) }
end
nth(n)
click to toggle source
def nth(n)
lambda { |*list| list[n] }
end
rotate(n = 1)
click to toggle source
def rotate(n = 1)
lambda { |*list| list.rotate(n) }
end
second()
click to toggle source
def second
lambda { |*list| list[1] }
end
tail()
click to toggle source
def tail
lambda { |*list| list[1..-1] }
end