[#60404] is RB_GC_GUARD needed in rb_io_syswrite? — Eric Wong <normalperson@...>
I haven't gotten it to crash as-is, but it seems like we need to
4 messages
2014/02/01
[#60682] volatile usages — Eric Wong <normalperson@...>
Hi all, I went ahead and removed some use of volatile which were once
5 messages
2014/02/13
[#60794] [RFC] rearrange+pack vtm and time_object structs — Eric Wong <normalperson@...>
Extracted from addendum on top of Feature #9362 (cache-aligned objects).
4 messages
2014/02/16
[#61139] [ruby-trunk - Feature #9577] [Open] [PATCH] benchmark/driver.rb: align columns in text output — normalperson@...
Issue #9577 has been reported by Eric Wong.
3 messages
2014/02/28
[ruby-core:60957] [ruby-trunk - Feature #9548] Module curry
From:
sam.rawlins@...
Date:
2014-02-22 00:22:11 UTC
List:
ruby-core #60957
Issue #9548 has been updated by Sam Rawlins.
Firstly, Proc has a #curry, though not as flexible as you would like: http://rubydoc.info/stdlib/core/Proc#curry-instance_method
Secondly, to implement such flexibility is not too hard in pure Ruby. Here is an implementation of arbitrary currying for Procs:
def curry(prc, *args)
Proc.new { |*remaining| prc.call(*args.map { |arg| arg || remaining.shift }) }
end
and one for Methods:
def curry_m(m, n, *args)
define_method(m, curry(method(n), *args))
end
Thusly, you can do:
power = ->(a,b){ "#{a}**#{b} is #{a**b}" }
square = curry power, nil, 2
pow2 = curry power, 2, nil
puts "3 squared is #{square.call(3)}" #=> 3 squared is 9
puts "two to the 3 is #{pow2.call(3)}" #=> two to the 3 is 8
list = ->(a,b,c,d) { "#{a}, #{b}, #{c}, #{d}" }
static_a = curry list, :hi, nil, nil, nil
static_b_c = curry list, nil, :sam, :adam, nil
puts "static_a: #{static_a.call(:b, :c, :d)}" #=> static_a: hi, b, c, d
puts "static_b_c: #{static_b_c.call(:a, :d)}" #=> static_b,c: a, sam, adam, d
def power_m(a,b); a**b; end
curry_m(:square_m, :power_m, nil, 2)
curry_m(:pow2_m, :power_m, 2, nil)
puts "3 squared is #{square_m(3)}" #=> 3 squared is 9
puts "two to the 3 is #{pow2_m(3)}" #=> two to the 3 is 8
gist: https://gist.github.com/srawlins/9146528
----------------------------------------
Feature #9548: Module curry
https://bugs.ruby-lang.org/issues/9548#change-45355
* Author: Boris Stitnicky
* Status: Open
* Priority: Normal
* Assignee:
* Category:
* Target version:
----------------------------------------
I would like to beg for either `Module#curry` method with syntax
```ruby
module Foo
curry( :sym2, :sym1, 0 => 42, 1 => 43, 3 => 44, foo: "bar" )
end
```
or `curry` directive similar to the existing `alias` directive
```ruby
module Foo
curry sym2 sym1( 42, 43, *, 44, foo: "bar )
end
```
Example usage:
```ruby
module MyMath
def power a, b
a ** b
end
curry square power( *, 2 )
curry square_root power( *, 0.5 )
curry cube( *, 3 )
curry pow2 power( 2, * )
curry pow_e power( Math::E, * )
curry pow10 power( 10, * )
end
```
--
http://bugs.ruby-lang.org/