Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PushLast.cs
1using System.Collections.Generic;
5
7{
12 {
13 private readonly VariableReference reference;
14
24 : base(new ScriptNode[] { Element, Vector }, new ArgumentType[] { ArgumentType.Normal, ArgumentType.Vector },
26 {
27 this.reference = Vector as VariableReference;
28 }
29
33 public override string FunctionName => nameof(PushLast);
34
38 public override string[] DefaultArgumentNames => new string[] { "x", "v" };
39
47 {
48 if (!(Arguments[1] is IVector V))
49 throw new ScriptRuntimeException("Expected second argument to be a vector.", this);
50
51 LinkedList<IElement> Elements = new LinkedList<IElement>();
52
53 foreach (IElement E in V.VectorElements)
54 Elements.AddLast(E);
55
56 Elements.AddLast(Arguments[0]);
57
58 IElement Result = V.Encapsulate(Elements, this);
59
60 if (!(this.reference is null))
61 Variables[this.reference.VariableName] = Result;
62
63 return Result;
64 }
65
66 }
67}
Base class for all types of elements.
Definition: Element.cs:13
Class managing a script expression.
Definition: Expression.cs:39
override string FunctionName
Name of the function
Definition: PushLast.cs:33
PushLast(ScriptNode Element, ScriptNode Vector, int Start, int Length, Expression Expression)
PushLast(v)
Definition: PushLast.cs:23
override string[] DefaultArgumentNames
Default Argument names
Definition: PushLast.cs:38
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: PushLast.cs:46
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Represents a variable reference.
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
IElement Encapsulate(ICollection< IElement > Elements, ScriptNode Node)
Encapsulates a set of elements into a similar structure as that provided by the current element.
Basic interface for vectors.
Definition: IVector.cs:9
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9