namespace Bts.ArithmeticExpressions; using System.Collections.Immutable; class ArithmeticProgram : IArithmeticProgram { readonly ImmutableList? assignments; public ArithmeticProgram(Assignment assignment) => assignments = ImmutableList.Empty.Add(assignment); public ArithmeticProgram(ImmutableList assignments) => this.assignments = assignments; IEnumerable IArithmeticProgram.OutputIdentifiers => assignments.empty_if_null() .Select(a => a.Identifier ?? throw new Exception("Identifier string is null")) .Distinct(); IDictionary IArithmeticProgram.Evaluate(IDictionary env) => assignments.empty_if_null().Aggregate(env, (e, a) => a.Evaluate(e)); }