             return .error("requires pair")
         }
     }
+
+    private func evaluateUserFunction(name: String, arguments: [Expression], context: Context) throws -> Expression {
+        guard let expr = context[name] else {
+            return .error("cannot evaluate call '\(name)' with arguments \(arguments)")
+        }
+        guard case let .closure(closureFunction, closureContext) = expr else { throw EvaluationError.notAFunction(expr) }
+        guard case let .subfunction(subfunction) = closureFunction else { throw EvaluationError.notAFunction(closureFunction) }
+        let body = subfunction.body
+        return body.evaluate(context: context)
+    }
 }

    case insufficientArguments
    case notANumber(Expression)
    case notABoolean(Expression)
}

extension Expression {

            if let funcName = subfunction.name {
                finalContext = extendContext(context: finalContext, name: funcName, value: closure)
            }
            return subfunction.body.evaluate(context: finalContext)
        default:
            return .error("closure does not wrap function")
        }
