# Convert a list with three arguments {x0,x1, step} into an equidistant table?

How can I convert a list such as:

a = {1, 2, 0.1}


into sequence so that I can pass them into a function, e.g. I want to be able to do something like this

Range[a]


so that the output will be:

1, 1.1, 1.2, ... , 2.0

-
I modified the title to make it a bit more informative and added some formatting - for your next questions please have a look at the FAQ and the markdown help. –  Yves Klett Feb 22 '13 at 7:20

You can use the Range function in this way:

Range[1, 2, 0.1]


to get

{1.,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2.}


If the problem is how to pass the parameter a you can use:

1- Using Apply.

a = {1, 2, 0.1}
Range@@a


The Apply operator (@@) "decapitates" the List head from list a and changes it by Range.

2- Using Sequence

a = {1, 2, 0.1};
Range[Sequence @@ a]


It's useful when you have another variables to pass. That's not your case, but I just wrote to be more didactical.

-
Thank you! That is exactly what I wanted. –  Raj Feb 22 '13 at 0:12
+1 for use of the verb "decapitate" –  gpap Feb 22 '13 at 8:22

Taking the last line of the question even more literally than Mr.Wizard

a = {1, 2, 0.1};
r = Range @@ a;
Row[{Sequence @@ r[[1 ;; 3]], "...", r[[-1]]}, ","]


1., 1.1, 1.2, ..., 2.

-
The audacity! +1 :-) –  Mr.Wizard Feb 22 '13 at 7:21
you need to go 1 level more literal and implement the cream bg with an orange dotted border on the left :D –  rm -rf Feb 22 '13 at 7:26
@rm-rf that wasn't in the original or it would have been really funny. –  Mr.Wizard Feb 22 '13 at 7:36

... you can also use ReplaceAll:

 a={1,2,.1};
a /. List->Range (* ReplaceAll *)
(* {1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.} *)


or, ReplacePart:

 ReplacePart[a, 0 -> Range]
(* {1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.} *)


or, set Part zero to Range (re-assign head):

 b=a; b[[0]]=Range;b

-
+1 for symbol[[0]]=newHead. –  Murta Feb 22 '13 at 10:21

Taking the last line of your question literally:

a = {1, 2, 0.1};

Row[Range @@ a, ","]

1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.


Also, to illustrate an alternative data format:

a = Sequence[1, 2, 0.1]

Range[a]

{1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.}

-
Thanks, that's also very useful to know for future use. As you can probably tell, I'm a newbie. –  Raj Feb 22 '13 at 0:39

Also

a = {1, 2, 0.1};
Table[i, {i, ##}] & @@ a

(*{1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.}*)

-