Skip to content

Instantly share code, notes, and snippets.

@airled
Created May 19, 2018 17:30
Show Gist options
  • Save airled/db56a70634c41943faa2c70280594933 to your computer and use it in GitHub Desktop.
Save airled/db56a70634c41943faa2c70280594933 to your computer and use it in GitHub Desktop.
simple Macro.prewalk implementation
defmodule Tr do
def tr(ast, fun) do
case fun.(ast) do
{x1, x2, [x3, x4]} -> {x1, x2, [tr(x3, fun), tr(x4, fun)]}
{x1, x2, x3} -> {x1, x2, tr(x3, fun)}
x -> x
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment