Created
May 19, 2018 17:30
-
-
Save airled/db56a70634c41943faa2c70280594933 to your computer and use it in GitHub Desktop.
simple Macro.prewalk implementation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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