How to make linspace work with one point?

question

#1

Currently,

linspace(1,10,1)

returns

ERROR: ArgumentError: linspace(1.0, 10.0, 1): endpoints differ

What’s the way to use multiple dispatch to grab the value of 1 and make a method like:

linspace(a,b,1) = a:1.0:a

I remember reading about this somewhere


#2

I’d consider that error a feature, not a bug. In my mind, the raison d’etre of linspace is to hit the endpoints exactly — that’s how it differs from the other constructions.

Multiple dispatch only works with types, not values, so you can’t use it to do something special when one of the arguments is the value 1.