Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Clojure have a function like Mathematica's %?

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.

like image 926
Tom LaGatta Avatar asked Dec 25 '22 19:12

Tom LaGatta


1 Answers

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.

like image 131
Arthur Ulfeldt Avatar answered Dec 30 '22 19:12

Arthur Ulfeldt