Is there is an autocompletion feature for brackets in Mathematica 10?

396 views Asked by At

I am new to Mathematica, have used RStudio before for R and like the feature for brackets' autocompletion. There are plenty of different brackets are used in Mathematica code and it is handy to have same feature there. May be I just missed where the setting for it is?

1

There are 1 answers

0
Szabolcs On

Go to Insert -> Typesetting to find the keyboard shortcuts for inserting matching [], () or {}. On OS X it's Option-Command-].

There's information on matching brackets in the documentation.


The good news is that this functionality is much less needed in Mathematica than in R. In Mathematica, instead of writing

f[g[h[x]]]

I like to write the completely equivalent but much more readable

f@g@h[x]

Instead of writing

lapply(arr, f)

we would write

f /@ arr

in Mathematica. This is equivalent to Map[f, arr] but has no brackets.

It's worth putting in some time to learn how to use these weird looking operators effectively. While it's certainly possible to use them to make your code cryptic and unintelligible, when used correctly, they can improve readability significantly. It just requires experience and a little discipline. I recommend you look at https://mathematica.stackexchange.com/ to get used to the idiomatic use of these operators.

While learning Mathematica keep in mind that there is a subjective (or "cultural") element to "readability". You'll need to get used to the community standards and common idioms before all of this starts making sense. That's why I suggest reading Mathematica.SE.


Update: I forgot to mention the somewhat annoying [[ ... ]] notation for Part. Go to the bottom my Mathematica page to see how to set up keyboard shortcuts for inserting the equivalent but more readable . esc [ esc also works but I find it too tedious.