First order calls with methods?

Hello!

Is there a short form for METHOD-calls?

f1=->{|x| sin(x)+cos(x) }
  [## ups: is there an implemented DRG-selector (for using 360°) ? ]

But like:
def f1(n) n*n end
def f2(n,m) n*m end
fvar= :f1; p fvar(3)
fvar = :f2; p fvar(2,3)
# or similar

Thx
Berg

Hello!

​Hi.​

Is there a short form for METHOD-calls?

f1=->{|x| sin(x)+cos(x) }
  [## ups: is there an implemented DRG-selector (for using 360°) ? ]

​Do you want a short form for calling `f1`? You can use the magic dot:

···

On 30 August 2016 at 19:19, A Berger <aberger7890@gmail.com> wrote:

~~~
irb(main):001:0> include Math
irb(main):002:0> f1 = ->x{ sin(x) + cos(x) }
irb(main):003:0> f1.(PI / 2)
=> 1.0
~~~

I don't know what you mean by "DRG-selector".

But like:
def f1(n) n*n end
def f2(n,m) n*m end
fvar= :f1; p fvar(3)
fvar = :f2; p fvar(2,3)
# or similar

​Do you mean, you want to capture a reference to the function and invoke it
later?

~~~
irb(main):001:0> def f1(n) n*n; end
irb(main):002:0> fvar = method :f1
=> #<Method: Object#f1>
irb(main):003:0> fvar.(3)
=> 9
~~~​

Thx
Berg

Hope this helps.​

Cheers
--
  Matthew Kerwin
  http://matthew.kerwin.net.au/

Hi
switching the base for trigonometric functions: 100%circle == 360° ==
100Neugrad == fully filled PI :wink:
Sure we could do some math instead...

Thanks for the shortened call!

Yes: store the reference to a method, to use it like procs/lambdas.

Thanks
Berg

Sometimes I feel like you don't even try?
http://bfy.tw/7T0s

···

On Tue, Aug 30, 2016 at 3:41 AM A Berger <aberger7890@gmail.com> wrote:

Hi
switching the base for trigonometric functions: 100%circle == 360° ==
100Neugrad == fully filled PI :wink:
Sure we could do some math instead...

Thanks for the shortened call!

Yes: store the reference to a method, to use it like procs/lambdas.

Thanks
Berg

Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;

--

- Raj

Sometimes?

They have basically driven me off of this list because people keep feeding the help vampire.

( http://slash7.com/2006/12/22/vampires/ )

···

On Aug 30, 2016, at 15:38, Raj Sahae <rajsahae@gmail.com> wrote:

Sometimes I feel like you don't even try?
http://bfy.tw/7T0s