private INode EvaluateLambdaFunction(LambdaFunctionNode head, List <INode> tail, Environment env) { var expectedCount = head.Parameters.Children.Count; var actualCount = tail.Count; if (actualCount != expectedCount) { return(new ErrorNode($"function takes exactly {expectedCount} arguments ({actualCount} given)")); } for (var i = 0; i < expectedCount; i++) { var key = ((SymbolNode)head.Parameters.Children[i]).Value; var value = tail[i]; env.Put(key, value); } return(BuiltinUnquote(new List <INode> { head.Body }, env)); }
protected bool Equals(LambdaFunctionNode other) { return(Equals(Parameters, other.Parameters) && Equals(Body, other.Body)); }
private INode VisitLambdaFunctionNode(LambdaFunctionNode node, Environment env) => node;