}
def sum_squares list {
- list.map(square) | sum _
+ list.map(square) | sum
}
def square_sum list {
- sum list | square _
+ sum list | square
}
-list::iota 1, 101 | (square_sum _) - (sum_squares _) | println _
+list::iota 1, 101 | (square_sum _) - (sum_squares _) | println
* then use RHS as our value */
sbIrExpr *left = compile_ast_expr(ck, node->op.left, FALSE);
put_assign(ck, pipe_var(ck), left);
- return compile_ast_expr(ck, node->op.right, FALSE);
+ sbIrExpr *right = compile_ast_expr(ck, node->op.right, FALSE);
+ if (!node->op.right->has_us) {
+ /* if there is no _ to the right of the "|", assume it is a function
+ * call that we are passing the left side to as a singular argument */
+ right = expr_call(ck, right, expr_list(ck, expr_var(ck, pipe_var(ck))));
+ }
+ return right;
} else {
sbIrExpr *left = NULL, *right = NULL;
if (node->op.left != NO_NODE) {
.op.type = operation,
.op.left = child,
.op.right = NO_NODE,
+ .has_us = child->has_us,
};
return new_node(pr, &n);
}
.op.type = operation,
.op.left = left,
.op.right = right,
+ .has_us = left->has_us || right->has_us,
};
return new_node(pr, &n);
}
.type = type,
.seq.left = left,
.seq.right = right,
+ .has_us = left->has_us || right->has_us,
};
return new_node(pr, &n);
}
.tri.left = left,
.tri.center = center,
.tri.right = right,
+ .has_us = left->has_us || center->has_us || right->has_us,
};
return new_node(pr, &n);
}
.type = type,
.seq.left = left,
.seq.right = NO_NODE,
+ .has_us = left->has_us,
};
return new_node(pr, &n);
}
PANIC("can't create name node with token of type %d", token.type);
}
+ flag has_us = FALSE;
+ if (sbstrncmp(sbSymbol_name(token.symb), "_", 1) == 0) {
+ has_us = TRUE;
+ }
+
sbAstNode n = (sbAstNode) {
.type = AST_NODE_NAME,
.symb = token.symb,
+ .has_us = has_us,
};
return new_node(pr, &n);
}