Пример #1
0
 /// <summary>
 /// Find the product of the Somes.
 /// For numeric values the behaviour is to multiply the Somes (lhs * rhs)
 /// For Lst values the behaviour is to multiply all combinations of values in both lists
 /// to produce a new list
 /// Otherwise if the T type derives from IMultiplicable then the behaviour
 /// is to call lhs.Multiply(rhs);
 /// </summary>
 /// <param name="lhs">Left-hand side of the operation</param>
 /// <param name="rhs">Right-hand side of the operation</param>
 /// <returns>lhs * rhs</returns>
 public OptionUnsafe <T> Multiply(OptionUnsafe <T> rhs)
 {
     if (IsNone)
     {
         return(this);             // zero * rhs = zero
     }
     if (rhs.IsNone)
     {
         return(rhs);              // lhs * zero = zero
     }
     return(TypeDesc.Multiply(Value, rhs.Value, TypeDesc <T> .Default));
 }
 /// <summary>
 /// Find the product of the Somes.
 /// For numeric values the behaviour is to multiply the Somes (lhs * rhs)
 /// For Lst values the behaviour is to multiply all combinations of values in both lists
 /// to produce a new list
 /// Otherwise if the T type derives from IMultiplicable then the behaviour
 /// is to call lhs.Multiply(rhs);
 /// </summary>
 /// <param name="lhs">Left-hand side of the operation</param>
 /// <param name="rhs">Right-hand side of the operation</param>
 /// <returns>lhs * rhs</returns>
 public static T?multiply <T>(T?lhs, T?rhs) where T : struct
 {
     if (!lhs.HasValue)
     {
         return(lhs);                // zero * rhs = zero
     }
     if (!rhs.HasValue)
     {
         return(rhs);                // lhs * zero = zero
     }
     return(TypeDesc.Multiply(lhs.Value, rhs.Value, TypeDesc <T> .Default));
 }
Пример #3
0
 public Lst <T> Multiply(Lst <T> rhs) =>
 (from x in this.AsEnumerable()
  from y in rhs.AsEnumerable()
  select TypeDesc.Multiply(x, y, TypeDesc <T> .Default)).Freeze();
Пример #4
0
 /// <summary>
 /// Multiply operator - runs through every combination of
 /// items in the two sets and performs a multiply operation on
 /// them; and then puts the result in a new distinct set.
 /// </summary>
 /// <param name="rhs">Right hand side set</param>
 /// <returns>Product of the two sets</returns>
 public Set <T> Multiply(Set <T> rhs) =>
 new Set <T>((from x in this.AsEnumerable()
              from y in rhs.AsEnumerable()
              select TypeDesc.Multiply(x, y, TypeDesc <T> .Default)), true);
Пример #5
0
 public NewType <T> Multiply(NewType <T> rhs) =>
 GetType() == rhs.GetType()
         ? (NewType <T>) NewType.Construct(GetType(), TypeDesc.Multiply(Value, rhs.Value, TypeDesc <T> .Default))
         : failwith <NewType <T> >("Mismatched NewTypes in multiply");