[This post needs better tags than I could come up with. Edits to the tags would be particularly welcome.]
I realize that it is trivial to define a function that takes an interval (i.e. two endpoints, $a < b$), and an integer $n > 1$, and returns a list of $n$ evenly spaced points $x_1 = a, x_2, \dots, x_{n-1}, x_n = b$,1 but still, given that this functionality is frequently needed, and is commonplace in other scientific computing environments, I am surprised not to be able to find a Mathematica built-in for it in the docs.
Did I miss it?
(BTW: I'd love to lay my hand on some stash of such "useful functions that should be included-by-default in Mathematica but aren't".)
1 For example,
linearmesh[a_, b_, n_Integer /; n > 1] := Range[a, b, (b - a)/(n - 1)]
linearmesh[10, 20, 300] // N // Short
{10.,10.0334,10.0669,10.1003,<<292>>,19.8997,19.9331,19.9666,20.}
Some may prefer this instead:
linearmesh2[a_, b_, n_Integer /; n > 0] := Range[a, b, (b - a)/n]
linearmesh2[10, 20, 300] // N // Short
{10.,10.0333,10.0667,10.1,10.1333,<<292>>,19.9,19.9333,19.9667,20.}
Etc.
I'm sure there are more clueful ways to implement this...
Range
. If you frequently need certain convenience wrappers forRange
, then put them in your initialization package. 2) As to a list of "useful functions that should be included-by-default in Mathematica but aren't", I suggest that what you would want to see on such a list would be very different from what I would want to see, and this would be true for any pair of users, making a universal version of such a list essentially impossible. The range of the interests of the user base is simply too broad. $\endgroup$FindDivisions
? Depends on how exact you need to be. $\endgroup$