Elegantly implementing 'map (+1) list' in ruby
ruby
Solution
Use the ampex gem, which lets you use methods of `X` to build up any proc one one variable. Here’s an example from its spec:
["a", "b", "c"].map(&X * 2).should == ["aa", "bb", "cc"]
Problem
The short code in title is in Haskell, it does things like ``` list.map {|x| x + 1} ``` in ruby. While I know that manner, but what I want to know is, is there any more elegant manners to implement same thing in ruby like in Haskell. I really love the `to_proc` shortcut in ruby, like this form: ``` [1,2,3,4].map(&:to_s) [1,2,3,4].inject(&:+) ``` But this only accept exactly matching argument number between the Proc's and method. I'm trying to seek a way that allow passing one or more arguments extra into the Proc, and without using an useless temporary block/variable like what the first demonstration does. I want to do like this: ``` [1,2,3,4].map(&:+(1)) ``` Does ruby have similar manners to do this?