Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
PopFirst.cs
1using System.Collections.Generic;
5
7{
12 {
13 private readonly VariableReference reference;
14
24 {
25 this.reference = Argument as VariableReference;
26 }
27
31 public override string FunctionName => nameof(PopFirst);
32
40 {
41 int c = Argument.Dimension;
42 if (c == 0)
43 return ObjectValue.Null;
44
45 IElement Result = Argument.GetElement(0);
46
47 if (!(this.reference is null))
48 {
49 ICollection<IElement> Elements = Argument.VectorElements;
50
51 if (!Elements.Remove(Result))
52 {
53 LinkedList<IElement> Elements2 = new LinkedList<IElement>();
54 bool First = true;
55
56 foreach (IElement E in Elements)
57 {
58 if (First)
59 First = false;
60 else
61 Elements2.AddLast(E);
62 }
63
64 Elements = Elements2;
65 }
66
67 Variables[this.reference.VariableName] = Argument.Encapsulate(Elements, this);
68 }
69
70 return Result;
71 }
72
73 }
74}
Class managing a script expression.
Definition: Expression.cs:39
PopFirst(ScriptNode Argument, int Start, int Length, Expression Expression)
PopFirst(v)
Definition: PopFirst.cs:22
override string FunctionName
Name of the function
Definition: PopFirst.cs:31
override IElement EvaluateVector(IVector Argument, Variables Variables)
Evaluates the function on a vector argument.
Definition: PopFirst.cs:39
ScriptNode Argument
Function argument.
Base class for funcions of one vector variable.
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
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Represents a variable reference.
static readonly ObjectValue Null
Null value.
Definition: ObjectValue.cs:86
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Basic interface for vectors.
Definition: IVector.cs:9