# Evaluating an expression on one line

Is it possible to evaluate an expresson on one line?

I have a linear algebra problem to re-write the straight line $$-x=1-3y=-1-2z$$ to a 'vector form';

line = {x, y, z} /. Solve[{{-x, 1 - 3 y, -1 - 2 z} == {1, 1, 1} t}, {x, y, z}][];


and I want to extract the 'fix/start point' and the directional vector of line (in lack of better knowledge of any inbuilt functions in M.) by

t = 0;
p0 = line;
t = 1;
n = line - p0;


These 4 lines I think could be merged to two lines, but I don't know the syntax for it, something in the line of

p0 = line @{t=0};
n = line-p0 @{t=1};


What is the correct syntax for this?

• mf67, may I suggest that you revisit your questions and consider accepting any answers that best solve your problem.
– kglr
Sep 22 '18 at 23:08
• There is a blue popup 'flash' each time but I don't manage to read it before it disappears. Are there instructions somewhere to read to correctly process answers?
– mf67
Sep 22 '18 at 23:54
• mf67, this may be useful: Accepting an aswer: how does it work
– kglr
Sep 23 '18 at 0:00

You can use ReplaceAll with a list of lists of rules ({a->b}):

line /. {{t -> 0}, {t -> 1}}


{{0, 1/3, -(1/2)}, {-1, 0, -1}}

To get p0 and n in a single line:

{p0, n} = {#, #2 - #} & @@ (line /. {{t -> 0}, {t -> 1}})


{{0, 1/3, -(1/2)}, {-1, -(1/3), -(1/2)}}

Note: The same trick in a simpler example:

x /. {{x -> 100}, {x -> 5}, {x -> abc}}


{100, 5, abc}