make interpmap composable
This commit is contained in:
parent
a6169ec2d0
commit
3e42db0cdf
@ -11,11 +11,15 @@ function astuples(xs)
|
|||||||
all(x->!(x==nothing), xs) ? xs : nothing
|
all(x->!(x==nothing), xs) ? xs : nothing
|
||||||
end
|
end
|
||||||
|
|
||||||
function interp(ctx, ::typeof(map), f, xs...)
|
function interpmap(cb)
|
||||||
f = interpret(ctx, f)
|
function interp(ctx, ::typeof(map), f, xs...)
|
||||||
xs = interpret(ctx, xs)
|
f, xs = interpret(ctx, (f, xs))
|
||||||
xs′ = astuples(xs)
|
xs′ = astuples(xs)
|
||||||
xs′ == nothing ? vertex(map, constant(f), xs...) : group(map(f, xs′...)...)
|
xs′ ≠ nothing ?
|
||||||
|
group(map(f, xs′...)...) :
|
||||||
|
cb(ctx, map, constant(f), xs...)
|
||||||
|
end
|
||||||
|
interp(args...) = cb(args...)
|
||||||
end
|
end
|
||||||
|
|
||||||
function interp(ctx, model, xs...)
|
function interp(ctx, model, xs...)
|
||||||
@ -25,4 +29,4 @@ function interp(ctx, model, xs...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
expand(graph, xs...) =
|
expand(graph, xs...) =
|
||||||
interp(Context(interplambda(interpconst(interptuple(interp)))), graph, xs...)
|
interp(Context(interplambda(interpmap(interpconst(interptuple(interp))))), graph, xs...)
|
||||||
|
Loading…
Reference in New Issue
Block a user