[#89806] [Ruby trunk Bug#15306] Generate prelude.c using miniruby — v.ondruch@...
Issue #15306 has been reported by vo.x (Vit Ondruch).
3 messages
2018/11/15
[ruby-core:89775] [Ruby trunk Feature#6284] Add composition for procs
From:
nobu@...
Date:
2018-11-12 12:43:29 UTC
List:
ruby-core #89775
Issue #6284 has been updated by nobu (Nobuyoshi Nakada).
I've forgotten to post the patch to use `<<` and `>>`.
https://github.com/nobu/ruby/tree/feature/6284-proc-composition
----------------------------------------
Feature #6284: Add composition for procs
https://bugs.ruby-lang.org/issues/6284#change-74839
* Author: pabloh (Pablo Herrero)
* Status: Open
* Priority: Normal
* Assignee: nobu (Nobuyoshi Nakada)
* Target version:
----------------------------------------
It would be nice to be able to compose procs like functions in functional programming languages:
```ruby
to_camel = :capitalize.to_proc
add_header = ->val {"Title: " + val}
format_as_title = add_header << to_camel << :strip
```
instead of:
```ruby
format_as_title = lambda {|val| "Title: " + val.strip.capitalize }
```
It's pretty easy to implement in pure ruby:
```ruby
class Proc
def << block
proc { |*args| self.call( block.to_proc.call(*args) ) }
end
end
```
---Files--------------------------------
0001-proc.c-Implement-Proc-for-Proc-composition.patch (3.65 KB)
0002-proc.c-Implement-Method-for-Method-composition.patch (2.67 KB)
0003-proc.c-Support-any-callable-when-composing-Procs.patch (3.97 KB)
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>