Skip to content

Show original code from source file when the code has pipeline forms#1

Open
zelixir wants to merge 3 commits into
romul:masterfrom
zelixir:master
Open

Show original code from source file when the code has pipeline forms#1
zelixir wants to merge 3 commits into
romul:masterfrom
zelixir:master

Conversation

@zelixir
Copy link
Copy Markdown

@zelixir zelixir commented Jan 23, 2019

Printing the original code will be better.

./test/dbg_test.exs:135
  list = [1, 2, 3]
  zero = 0
  list
  |> Enum.map(&{&1, to_string(&1 * &1)})
  |> Enum.into(%{})
  |> Map.put(zero, to_string(zero)) #=> %{0 => "0", 1 => "1", 2 => "4", 3 => "9"}

@romul
Copy link
Copy Markdown
Owner

romul commented Jan 23, 2019

Wow, that's an excellent idea! But I think it could be done much simpler, we have filename, so all we need is to determine line_min & line_max (minus 1) and then we can just do

File.read!(filename) |> String.split("\n") |> Enum.slice(line_min..line_max)

@zelixir
Copy link
Copy Markdown
Author

zelixir commented Jan 24, 2019

Yes, Enum.slice/2 is my blind spot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants