[#78949] [Ruby trunk Feature#13095] [PATCH] io.c (rb_f_syscall): remove deprecation notice — kosaki.motohiro@...
Issue #13095 has been updated by Motohiro KOSAKI.
3 messages
2017/01/03
[#78997] [Ruby trunk Bug#13110] Byte-based operations for String — shugo@...
Issue #13110 has been updated by Shugo Maeda.
3 messages
2017/01/06
[#79228] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150] — Eric Wong <normalperson@...>
naruse@ruby-lang.org wrote:
5 messages
2017/01/23
[#79511] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150]
— Eric Wong <normalperson@...>
2017/02/13
Eric Wong <normalperson@yhbt.net> wrote:
[#79518] Re: [ruby-cvs:64576] naruse:r57410 (trunk): Prevent GC by volatile [Bug #13150]
— Nobuyoshi Nakada <nobu@...>
2017/02/13
On 2017/02/13 10:04, Eric Wong wrote:
[#79298] [Ruby trunk Bug#13085][Assigned] io.c io_fwrite creates garbage — nobu@...
Issue #13085 has been updated by Nobuyoshi Nakada.
3 messages
2017/01/29
[#79337] Re: [ruby-changes:45397] normal:r57469 (trunk): io.c: recycle garbage on write — SASADA Koichi <ko1@...>
Eric:
4 messages
2017/01/31
[#79352] Re: [ruby-changes:45397] normal:r57469 (trunk): io.c: recycle garbage on write
— Eric Wong <normalperson@...>
2017/01/31
SASADA Koichi <ko1@atdot.net> wrote:
[ruby-core:79032] [Ruby trunk Feature#12854] Proc#curry should return an instance of the class, not Proc
From:
chad@...
Date:
2017-01-10 02:06:29 UTC
List:
ruby-core #79032
Issue #12854 has been updated by Chad Brewbaker.
Defining complex functions with curry would be nontrivial:
~~~ ruby
double = ->(a)(a+a)
g = ->(a,b,c){ f.call(1,c, double.call(a))}
~~~
I suggest adding Proc#trans and Proc#lens.
Proc#trans applies a transformation (repeated permutation) to the argument list.
Proc#lens is list of functions applied to the argument list. Think of a constant as a function that takes zero arguments.
~~~ ruby
class Proc
def trans(*args)
->(*a){
a.flatten!
bound = [a.size, args.size].min
alist = (0...bound).collect{|i| a[args[i] ] }
self.call(alist)
}
end
def lens(*args)
concretes = [Integer,TrueClass,FalseClass,String,Float,Symbol,Array,Hash]
->(*a){
a.flatten!
bound = [a.size, args.size].min
alist = (0...bound).collect{|i|
if(concretes.include?(args[i].class))
args[i]
else
args[i].call(a[i])
end
}
self.call(alist)
}
end
end
id = ->(*args){args.inspect}
f = id.trans(0,1,2)
p f.call(0,1,2) == "[[0, 1, 2]]"
g = id.trans(2,0,0)
p g.call() == "[[]]"
p g.call(0) == "[[nil]]"
p g.call(0,1) == "[[nil, 0]]"
p g.call(0,1,2) == "[[2, 0, 0]]"
p g.call(0,1,2,3,4) == "[[2, 0, 0]]"
single = ->(a){a}
double = ->(a){a+a}
triple = ->(a){a+a+a}
q = id.lens(single, double,triple)
p q.call(5,5,5) == "[[5, 10, 15]]"
p q.call(1,2,3) == "[[1, 4, 9]]"
h = q.lens(single,double,triple)
p h.call(5,5,5) == "[[5, 20, 45]]"
k = id.lens(single, 444,triple)
p k.call(4,4,4,4,4) == "[[4, 444, 12]]"
~~~
Link, pull reqs welcome, https://github.com/chadbrewbaker/endoscope/blob/master/catgist.rb
----------------------------------------
Feature #12854: Proc#curry should return an instance of the class, not Proc
https://bugs.ruby-lang.org/issues/12854#change-62439
* Author: Ryan Davis
* Status: Feedback
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
~~~ ruby
class ChainedProc < Proc
end
ChainedProc.new { |x, y, z| 42 }.curry.class # => Proc
~~~
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>