feat: Add ArithmeticExpressions csproj
This commit is contained in:
1 parent
e4f276be2a
commit
ca95ab7a24
26 files changed
+2465
-1
No files matched your search
@@ -0,0 +1,21 @@
|
||||
namespace Bts.ArithmeticExpressions;
|
||||
|
||||
using System.Collections.Immutable;
|
||||
|
||||
class ArithmeticProgram : IArithmeticProgram {
|
||||
readonly ImmutableList<Assignment>? assignments;
|
||||
|
||||
public ArithmeticProgram(Assignment assignment) =>
|
||||
assignments = ImmutableList<Assignment>.Empty.Add(assignment);
|
||||
|
||||
public ArithmeticProgram(ImmutableList<Assignment> assignments) =>
|
||||
this.assignments = assignments;
|
||||
|
||||
IEnumerable<string> IArithmeticProgram.OutputIdentifiers =>
|
||||
assignments.empty_if_null()
|
||||
.Select(a => a.Identifier ?? throw new Exception("Identifier string is null"))
|
||||
.Distinct();
|
||||
|
||||
IDictionary<string, object?> IArithmeticProgram.Evaluate(IDictionary<string, object?> env) =>
|
||||
assignments.empty_if_null().Aggregate(env, (e, a) => a.Evaluate(e));
|
||||
}
|
||||
Reference in new issue
Block a user