In Elixir REPL iex, how can I suppress long pattern matching results

In Elixir repl, iex, when I complete the task, I get the result of matching a pattern printed in yellow:

enter image description here

This is great until the pattern match is long, for example a file:

enter image description here

... and, obviously, if it is a large file, it a) takes forever (not because of reading time, but to prepare for printing to match the screen pattern), and then b) it has been scrolling for centuries.

How can I suppress this behavior or limit the size of the pattern matching output?

+4
source share
2 answers

How Elixir REPL prints your terms

Elixir REPL by default limits the length of output for printing:

iex(16)> Enum.to_list(1..100)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 
 42, 43, 44, 45, 46, 47, 48, 49, 50, ...]

, Kernel.inspect/2 :limit. , Kernel.inspect Enum.to_list(1..100), limit: :infinity .

:limit , charlists File.read/1 ( UTF-8). , , inspect/2 ( ):

Kernel.inspect File.read!("a.txt"), limit: 60, binaries: :as_binaries

, Enum.each/2 :

File.stream!("a.txt") |> Enum.each fn line -> IO.puts line end

.

+2

(; 0 ) , iex , :

iex(1)> a = Enum.to_list(1..100); 0
0
iex(2)> a
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
 43, 44, 45, 46, 47, 48, 49, 50, ...]
+6

Source: https://habr.com/ru/post/1652867/


All Articles