Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
LambdaOrder.cs
1using System;
2using System.Collections.Generic;
5
6namespace Waher.Script.Order
7{
11 public class LambdaOrder : IComparer<IElement>
12 {
13 private readonly ILambdaExpression lambda;
14 private readonly IElement[] arguments;
15 private readonly Variables variables;
16
23 {
24 this.lambda = Lambda;
25 this.arguments = new IElement[2];
26 this.variables = Variables;
27 }
28
35 public int Compare(IElement x, IElement y)
36 {
37 this.arguments[0] = x;
38 this.arguments[1] = y;
39
40 IElement Result = this.lambda.Evaluate(this.arguments, this.variables);
41
42 return Math.Sign(Expression.ToDouble(Result));
43 }
44 }
45}
Class managing a script expression.
Definition: Expression.cs:39
static double ToDouble(object Object)
Converts an object to a double value.
Definition: Expression.cs:4824
Orders elements based logic defined in a lambda expression.
Definition: LambdaOrder.cs:12
int Compare(IElement x, IElement y)
Compares two elements.
Definition: LambdaOrder.cs:35
LambdaOrder(ILambdaExpression Lambda, Variables Variables)
Orders elements based logic defined in a lambda expression.
Definition: LambdaOrder.cs:22
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:20
Base interface for lambda expressions.