[{100, 0}, {{:div, [], [5]}, 0}, {{:div, [], [2]}, 0}] fun = fn {x, pos}, acc -> Macro.pipe(acc, x, pos) end :lists.foldl(fun, 100, [{{:div, [], [5]}, 0}, {{:div, [], [2]}, 0}]) # {:div, [], [{:div, [], [100, 5]}, 2]} Macro.to_string({:div, [], [{:div, [], [100, 5]}, 2]}) # "div(div(100, 5), 2)"