Is it possible to evaluate the current line?

  1. Is it possible to evaluate the current line? Suppose I have:
guess = [0, 0, 1, 1]
code = [0, 1, 0, 1]
Enum.zip(guess, code)
|> Enum.map(fn {a, b} -> [a, b] end)
|> Enum.count(fn [left, right] -> left == right end)

After writing line 3, Enum.zip(guess, code) I can evaluate the cell and see the result. Is there a way to evaluate line 3 afterwards? (Yes, I can comment the lines, etc., but it would be much more convenient to be able to evaluate the current line.)

  1. In livebook, how do I switch between Navigation Mode and Insert Mode from the keyboard?
1 Like

Put it in a different cell or put an IO.inspect in the pipeline?

2 Likes
  1. This doesn’t necessarily answer your question today, but come Elixir 1.14, dbg will be an excellent solution to this. You’d append dbg() to your pipeline as below, and you’d be able to see the output of each step of the pipeline.
Enum.zip(guess, code)
|> Enum.map(fn {a, b} -> [a, b] end)
|> Enum.count(fn [left, right] -> left == right end)
|> dbg()
  1. From navigation mode, just hit enter and it should switch to insert mode for the current cell. From insert mode, hit esc. (I’ve found that I sometimes need to hit esc twice.)
3 Likes