# Shortcut for Range[]?

I use Range a lot. Is there any syntactic shortcut for it, or do you always have to spell it out?

-
You could use the Notation Package to define a custom shortcurt for it. –  William Briand Oct 20 '13 at 13:41
I think, William means a custom alias using the esc keys. Or you could even define your own shorthand function. R=Range;. You could also try typing R and then pressing Command+(Shift)+K (or the equivalent windows keys) for autocompletion and templates. Yet another option may be to check out Halirutan's IntelliJIdea plugin. –  Timothy Wofford Oct 20 '13 at 13:49
Why don't you try r = Range;? –  Artes Oct 20 '13 at 14:31

If you want a nicer layout for Range you could try the Notation package:

Notation is a bit picky about the definition code of your notation. It has to go manually via its templates. That's why I used a picture above. The following code should work when copied:

<< Notation

CellPrint@Cell[BoxData[
RowBox[{"InfixNotation", "[",
RowBox[{
TemplateBox[{"\[TripleDot]"},
"NotationTemplateTag"], ",", "Range"}], "]"}]], "Input"]


After executing those two lines, a third one will appear which must be executed as well. After that you can use the \[TripleDot] character to define ranges:

5 \[TripleDot] 9


{5, 6, 7, 8, 9}

If you just want shorter code you can define:

r = Range;
r@5
r[3, 9, 2]


{1, 2, 3, 4, 5}

{3, 5, 7, 9}

-
The Notation package method is very nice. Just a shame that, as things are, you must still either type, literally, "[\TripleDot]" or else create an Escape alias for it. (Unfortunately, Esc ... Esc is already preempted for \[Ellipsis]. –  murray Oct 20 '13 at 22:43

The reference page for gives variations which utilize default arguments:

Range[20]
Range[1,20]
Range[1,20,1]


An alternative for this usage is Array

Array[#&,20]


If you are after a list of numbers, you could use Table

Range[6,20,2]
Table[i,{i,6,20,2}]


But if you are just using the output of Range as indices for Part then you might want to look at Span

f[[Range[6,20,2]]]
f[[6;;20;;2]]

-
Using the shortcut ;; for Span does make code shorter than directly using Range for indexing. But @Sjoerd C. de Vries's method using the Notation package and \[TripleDot]` makes indexing expressions more closely resemble traditional mathematical notation. –  murray Oct 20 '13 at 22:46