π = Math::PI
And after using this tiny substitution, my code became way more readable.So, for fun, I felt the urge to add many more mathematical symbols to be able to write a Fourier series like:
a0 + (1..n).∑ { |n| a[n]*sin(2*π*n*x/p) + b[n]*cos(2*π*n*x/p) }
So I continued doing this and added support for ∀, ∃, ∄ in Enumerable, even without immediate use, and kept going adding more stuff.This became this simple gem, that could be used either as refinement or monkey patch.
So I started to wonder if this wouldn't be useful to anyone else besides being a joke.
Being used at a script that only me (and possibly my wife) would read may be fun but pointless.
Assuming that in most cases code is read a few more times than written, it would make sense to take advantage of the possibilities of other Unicode characters to write mathematical functions and this joke could be useful.
What do you think?
(BTW, I also did this to play with static typing and refinements in Ruby and got a bit frustrated for the lack of support having to duplicate a lot of code. Tips and advices would be very appreciated)