4

In Mathematica, the % function yields the value on the previous line. Is there a corresponding function in Clojure (Leiningen REPL)?

Mathematica Documentation:

%n or Out[n] is a global object that is assigned to be the value produced on the n^(th) output line.

% gives the last result generated.

%% gives the result before last. %%...% (k times) gives the k^(th) previous result.

2
  • 1
    It's worth noting that you can get a keyboard interface (with searching) for command history in the REPL using Leiningen, or by invoking Clojure with rlwrap. That's not what you asked for, however. Commented Oct 15, 2013 at 13:15
  • @Mars, thanks! That's a good fact to know anyway. I'll play around with rlwrap. Commented Oct 16, 2013 at 6:31

1 Answer 1

10

yes, partially. From the REPL you get the previous three results:

*1 for the most recent result
*2 for the next most recent
*3 for the third most, though that's all you get.
*e for the most recent exception that made it to the top level.

It seems not to have arbitrary recall like Mathmatica though. It is also worth noting that these are only available from the repl, not in your functions or namespaces.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.