@@ 59,17 59,17 @@ NOTE: does the real work of counting arguments."""
s += '(' # Infix-separated arguments. (, for functions)
if infix is True: # Interpret `infix`.
- c_infix = " " + cname + " "
+ infix = " " + cname + " "
elif not isinstance(infix, str):
assert infix is False
- c_infix = ", "
+ infix = ", "
if n > 0: # The arguments come from the generator.
c_outputs = listing_do_c_args(gen, n,
self[1], cname or '(')
# Need it reversed.
c_outputs = reversed(list(c_outputs))
- s += c_infix.join(''.join(cl) for cl in c_outputs)
+ s += infix.join(''.join(cl) for cl in c_outputs)
if surround:
s += ")"
@@ 46,6 46,8 @@ class IBVariant(tuple, BaseFunctionVariant):
from type_stack_calc.util.markings_in_stack import markings_in_stack
from type_stack_calc.util.stack_check import assert_acceptable_vals
+# For infixing a bunch of names automatically.
+from type_stack_calc.util.fun_info import infixed_set
# NOTE: with "more advanced" type compilation, i noticed might want to note
# some of the results on the object instead of re-calculating.
@@ 53,9 55,11 @@ from type_stack_calc.util.stack_check import assert_acceptable_vals
class SimpleInbuildFunction(BaseFunction):
"""Relatively simple inbuild function."""
- def __init__(self, args, fun, name=None, infix=False, with_vars=False,
+ def __init__(self, args, fun, name=None, infix=None, with_vars=False,
destructive=False, definitional=False, extract_n=None,
tp='method'):
+ infix = (infix is None and name in infixed_set) or infix or False
+
BaseFunction.__init__(self, name, args, infix, with_vars,
destructive, definitional, tp)
self.fun = fun