3
$\begingroup$

How can I import a file without its expressions being evaluated ? E.g. assume that the file "test.m" contains just the list

{a, a + b + b + c, d}

If I use

Get["test.m"]

I obtain

{a, a + 2 b + c, d}

although I would like to get the unevaluated expression.

$\endgroup$
4
$\begingroup$

You could try using ReadList instead. For example:

ReadList[
    StringToStream @ "{a,a+b+b+c,d}",
    Hold[Expression]
]

{Hold[{a, a + b + b + c, d}]}

$\endgroup$
4
$\begingroup$

Also possible are

Import["test.m",{"Package","HeldExpressions"}]

returning

  {HoldComplete[{a, a + b + b + c, d}]}

and

 Import["test.m",{"Package","InactivatedExpressions"}]

giving

{{a, Inactive[Plus][a, b, b, c], d}}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.