Files
mgmt/lang/interpret_test/TestAstFunc1/shape8.txtar
James Shubin 2b820da311 lang: ast: structs, funcs: structs: Exprif without a channel
This adds an improved "expr if" which only adds the active branch to the
graph and removes the "secret" channel.
2025-08-04 17:45:06 -04:00

39 lines
829 B
Plaintext

-- main.mcl --
$gt = func($one, $two) {
$one > $two
}
$lambda1 = func($x) {
$x + "!"
}
$lambda2 = func($x) {
$x + "?"
}
$lambda = if $gt(10, 0) { # must be a const, otherwise this is a dynamic graph
$lambda1
} else {
$lambda2
}
test [$lambda("hello"),] {}
-- OUTPUT --
Edge: _operator -> exprif # condition
Edge: call -> callSubgraphOutput # dummy
Edge: callSubgraphOutput -> composite: []str # 0
Edge: const: int(0) -> _operator # b
Edge: const: int(10) -> _operator # a
Edge: const: str(">") -> _operator # op
Edge: exprIfSubgraphOutput -> call # fn
Edge: exprif -> exprIfSubgraphOutput # dummy
Vertex: _operator
Vertex: call
Vertex: callSubgraphOutput
Vertex: composite: []str
Vertex: const: int(0)
Vertex: const: int(10)
Vertex: const: str(">")
Vertex: const: str("hello")
Vertex: exprIfSubgraphOutput
Vertex: exprif