Allow Unicode symbols to be used as operators
It would be great to define mathematical operators (e.g. ∀, ∑, ∩) in F#, and be able to use other Unicode symbols (such as arrows) in operators as well. So instead of saying
let inline (!++) xs = xs |> Seq.sum
you could say
let inline (~∑) xs = xs |> Seq.sum
Writing "∑myList" is much, much easier on the eyes and brain than trying to figure out what "!++myList" does.
Eric Taucher commented
Get's my vote.
As an alternative means of entering the characters, one draws the character and has it entered. Here is an example of where a site takes in a drawing and converts it to a character or characters. After a while it can use Bayesian network or something to pick the one you mean. http://shapecatcher.com/
Heather Cynede commented
Here is Unicode letters implementation: http://heather.cynede.net/2013/04/f-unicode-in-action.html
But I need help with Unicode operators for now =)
There are a few other reputable survey sites that aren't listed, but you do have a nice list of some of the best ones.
See http://apollo13cn.blogspot.com/2012/09/math-unicode-symbol-add-on-for-f.html for a Visual Studio add-on.
I've got a modern APL Keyboard (you can order them from UNICOMP with USB) and I'd love to have this feature.
would be very cool. very cool. good bang for the buck feature methink.
Gustavo Guerra commented
It's not hard to type. You set up the greek keyboard on control panel and then and set a global hotkey like Ctrl+Alt+Shift to switch from/to it, then the ∑ is just the capital S, and similar for other symbols
Jon Harrop commented
This would be awesome!
Finn Neuik commented
I've been learning a little Haskell recently and something I like about the emacs mode is that it'll do a conversion on the fly between standard keywords and unicode representations. For example typing -> results in emacs showing →. It's nice seeing things like composition, nil, etc appearing 'correctly' and you easily add more. The source code itself remains with the standard characters. It'd be great to see something similar in F# (or rather Visual Studio) as I find it sometimes makes code a little opaque when you have to chase definitions of operators. The only issue with the emacs mode is that it messes with the whitespace (e.g. forall and . ∀ , use a different number of characters) but I'm guessing that could be worked out.
Daniel Jackson commented
With much improved intellisense, typing these operators might not be as big of an issue. <sarcasm>Alternatively, you could try and convince your employer to provide and gift you an "Optimus Maximus" keyboard.</sarcasm>
N N commented
Does anyone remember those APL keyboards? http://world.std.com/~jdostale/kbd/SpaceCadet.html
Yusuf Motara commented
It's a bit annoying on Windows, since you have to set it up by editing a registry value and rebooting (see http://en.wikipedia.org/wiki/Alt_code).
Then to type ∑, you turn on NumLock, hold down Alt, then press the following keys in turn: U, Numpad-Plus, 2, 2, 1, 1. (2211 is the Unicode character ∑; it can be typed either on the top-row of numbers or on the numpad). You can find more mathematical symbols here: http://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode
That's a cool idea, but how do you type these characters? I'm using the macro keys on my Logitech G15 (1st gen) keyboard, but I find it far from ideal.