Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

6
  • 9
    $\begingroup$ Range /@ Range[10] :-D $\endgroup$ Commented Apr 15, 2016 at 10:41
  • $\begingroup$ @JasonB: What? Hahaha... That really works. I am new in Mathematica. And haven't learnt that symbol '\@'. Could you explain? $\endgroup$ Commented Apr 15, 2016 at 10:44
  • 1
    $\begingroup$ So Range[x] will give {1, 2, 3, 4, 5,......x}, and /@ is the infix notation for Map. As an example, look f /@ {1, 2, 3} gives {f[1], f[2], f[3]}. So in the above, Range[10] gives {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, and then I'm just mapping Range onto that list $\endgroup$ Commented Apr 15, 2016 at 10:47
  • 1
    $\begingroup$ at least closely related: generate successive sublists from a list? $\endgroup$ Commented Apr 15, 2016 at 11:46
  • 1
    $\begingroup$ Or Range@Range[10]. See here under 'neat examples' $\endgroup$ Commented Apr 15, 2016 at 17:26