# Path: pycell/eval_.py
# def eval_expr(expr, env):
#     typ = expr[0]
#     if typ == "number":
#         return ("number", float(expr[1]))
#     elif typ == "string":
#         return ("string", expr[1])
#     elif typ == "none":
#         return ("none",)
#     elif typ == "operation":
#         return _operation(expr, env)
#     elif typ == "symbol":
#         name = expr[1]
#         ret = env.get(name)
#         if ret is None:
#             raise Exception("Unknown symbol '%s'." % name)
#         else:
#             return ret
#     elif typ == "assignment":
#         var_name = expr[1][1]
#         if var_name in env.items:
#             raise Exception("Not allowed to re-assign symbol '%s'." % var_name)
#         val = eval_expr(expr[2], env)
#         env.set(var_name, val)
#         return val
#     elif typ == "call":
#         return _function_call(expr, env)
#     elif typ == "function":
#         return ("function", expr[1], expr[2], Env(env))
#     else:
#         raise Exception("Unknown expression type: " + str(expr))


from pycell.eval_ import eval_expr


def if_(env, t, then_fn, else_fn):
    if t[0] != "number":
        raise Exception(
            (
                "Only numbers may be passed to an if, but I was passed '%s'"
            ) % str(t)
        )
    to_call = then_fn if t[1] != 0 else else_fn

# Path: pycell/eval_.py
# def eval_expr(expr, env):
#     typ = expr[0]
#     if typ == "number":
#         return ("number", float(expr[1]))
#     elif typ == "string":
#         return ("string", expr[1])
#     elif typ == "none":
#         return ("none",)
#     elif typ == "operation":
#         return _operation(expr, env)
#     elif typ == "symbol":
#         name = expr[1]
#         ret = env.get(name)
#         if ret is None:
#             raise Exception("Unknown symbol '%s'." % name)
#         else:
#             return ret
#     elif typ == "assignment":
#         var_name = expr[1][1]
#         if var_name in env.items:
#             raise Exception("Not allowed to re-assign symbol '%s'." % var_name)
#         val = eval_expr(expr[2], env)
#         env.set(var_name, val)
#         return val
#     elif typ == "call":
#         return _function_call(expr, env)
#     elif typ == "function":
#         return ("function", expr[1], expr[2], Env(env))
#     else:
#         raise Exception("Unknown expression type: " + str(expr))


# Path: pycell/prologue/native/if_.py
from pycell.eval_ import eval_expr



def if_(env, t, then_fn, else_fn):
    if t[0] != "number":
        raise Exception(
            (
                "Only numbers may be passed to an if, but I was passed '%s'"
            ) % str(t)
        )
    to_call = then_fn if t[1] != 0 else else_fn

    return eval_expr(("call", to_call, []), env)