-- main.mcl -- $funcgen = func() { func($a) { if $a { func($b) { if $b == "hello" { func() { "hey" } } else { func() { $b } } } } else { func($b) { func() { "wow: " + $b } } } } } $fn = $funcgen() $fn1 = $fn(true) $fn2 = $fn(false) $out1 = $fn1("hello") $out2 = $fn1("there") $out3 = $fn2("hello") $out4 = $fn2("world") $name1 = $out1() $name2 = $out2() $name3 = $out3() $name4 = $out4() test [$name1,] {} # hey test [$name2,] {} # there test [$name3,] {} # wow: hello test [$name4,] {} # wow: world -- OUTPUT -- Vertex: test[hey] Vertex: test[there] Vertex: test[wow: hello] Vertex: test[wow: world]