In Jupyter notebook, is there any way to re-use the output the line above, within a cell?
Coming from Mathematica, I often find it useful to write things commands which work on the output of the last line using %
, here's a stupid example:
Integrate[f[x],x]
Limit[%,x->1] - Limit[%,x->0]
In general one can write %%%
for 3rd-last output etc. https://reference.wolfram.com/language/ref/Out.html
@nostradamus reminds me that underscore _
is the output of the last cell, at least in Python. (Get last answer .) I didn't initially ask this, but would particularly like to be able to do this within a cell, so as to be able to execute multiple steps with one shift-enter.
I would also like to know if there's a way of doing either of these in Julia instead of Python.
You can use "_" and works generally in python environment.
In julia, ans
stores the result of evaluating the last statement.
4*2
ans/2
You may also be interested in checking out the piping syntax
4*2 |>
sqrt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With