Algebraic data types: Difference between revisions
Content added Content deleted
(→{{header|jq}}: def node:) |
|||
Line 1,149: | Line 1,149: | ||
def E: []; # the empty node |
def E: []; # the empty node |
||
def |
def b(x): bindings({} | x) // empty; |
||
# Input: [$color, $left, $value, $right] |
# Input: [$color, $left, $value, $right] |
||
def balance: |
def balance: |
||
def node: [R, [B, .a, .x, .b], .y, [B, .c, .z, .d]]; |
|||
| [R, [B, .a, .x, .b], .y, [B, .c, .z, .d]]) |
|||
(b([B, [R, [R, {a}, {x}, {x}], {y}, {c}], {z}, {d}]) | node) |
|||
// (b([B, [R, {a}, {x}, [R, {b}, {y}, {c}]], {z}, {d}]) | node) |
|||
// ( |
// (b([B, {a},{x}, [R, [R, {b}, {y}, {c}], {z}, {d}]]) | node) |
||
// (b([B, {a},{x}, [R, {b}, {y}, [R, {c}, {z}, {d}]]])| node) |
|||
// ( |
// (b([{col}, {a}, {x}, {b}]) |
||
| [.col, .a, .x, .b ]) ; |
|||
// (binding([{col}, {a}, {x}, {b}]) |
|||
| [.col, .a, .x, .b ]) ; |
|||
# Input: a node |
# Input: a node |
||
Line 1,221: | Line 1,219: | ||
15 |
15 |
||
</pre> |
</pre> |
||
=={{header|Julia}}== |
=={{header|Julia}}== |