Example #1
0
        /// <summary>
        /// String representation.
        /// </summary>
        /// <returns>String representation.</returns>
        public override string ToString()
        {
            List <string> itemsList = new List <string>();

            if (Predicates != null)
            {
                foreach (var predicateAtom in Predicates)
                {
                    itemsList.Add(predicateAtom.ToString(IdManager.Predicates));
                }
            }
            if (NumericFunctions != null)
            {
                foreach (var numericFunction in NumericFunctions)
                {
                    string functionAtom = numericFunction.Key.ToString(IdManager.Functions);
                    string numericValue = (NumericFunction.IsValueUndefined(numericFunction.Value)) ? "undefined" : numericFunction.Value.ToString(CultureInfo.InvariantCulture);
                    itemsList.Add($"(= {functionAtom} {numericValue})");
                }
            }
            if (ObjectFunctions != null)
            {
                foreach (var objectFunction in ObjectFunctions)
                {
                    string functionAtom = objectFunction.Key.ToString(IdManager.Functions);
                    string constValue   = IdManager.Constants.GetNameFromId(objectFunction.Value);
                    itemsList.Add($"(= {functionAtom} {constValue})");
                }
            }
            return(string.Join(", ", itemsList));
        }
Example #2
0
 /// <summary>
 /// Defines a new value for the requested function in the state.
 /// </summary>
 /// <param name="function">Requested function.</param>
 /// <param name="assignment">Value to be assigned.</param>
 public void AssignNumericFunction(IAtom function, double assignment)
 {
     if (NumericFunction.IsValueUndefined(assignment))
     {
         if (NumericFunctions != null && NumericFunctions.ContainsKey(function))
         {
             NumericFunctions.Remove(function);
         }
     }
     else
     {
         CheckNumericFunctionsInitialized();
         NumericFunctions[function] = assignment;
     }
 }