From: muraken@... Date: 2021-04-01T03:14:48+00:00 Subject: [ruby-core:103144] [Ruby master Feature#17769] Proposal: numeric coefficient syntax Issue #17769 has been updated by mrkn (Kenta Murata). File num_coeff.patch added I replaced the attached patch with changes to accept not only `2x` but also `2(x + 1)`. ---------------------------------------- Feature #17769: Proposal: numeric coefficient syntax https://bugs.ruby-lang.org/issues/17769#change-91217 * Author: mrkn (Kenta Murata) * Status: Open * Priority: Normal ---------------------------------------- When we write a mathematical equation, we often omit a multiplication operator between a coefficient and a variable like `2x`. I guess this convention can be useful in computer programming. Practically, Julia employs this notation: ``` julia> 2pi 6.283185307179586 julia> x = 3 3 julia> 2x 6 julia> pi �� = 3.1415926535897... julia> 2pi 6.283185307179586 ``` I wrote a proof-of-concept patch to introduce this notation in Ruby. We can write the following with this patch: ``` irb(main):001:0> x = 3 => 3 irb(main):002:0> 2x => 6 irb(main):003:0> def pi = Math::PI => :pi irb(main):004:0> 2pi => 6.283185307179586 ``` ---Files-------------------------------- num_coeff.patch (394 Bytes) -- https://bugs.ruby-lang.org/ Unsubscribe: