/// <summary> /// Factoryに指定した文字列からSequenceを生成する(separatorで分解せず、ただ一つのSequenceを生成) /// </summary> /// <returns></returns> public MathObject CreateSingle() { var xs = CreateMain().ToArray(); if (xs.Length == 0) { return(new MathSequence(Array.Empty <MathObject>(), "", _source.ToOriginalString())); } else if (xs.Length == 1) { return(xs[0]); } else { return(new MathSequence(xs, ",", _source.ToOriginalString())); } }
public MathSequence(MathToken token, Token leftBracket, Token rightBracket) : this(token) { LeftBracket = leftBracket; RightBracket = rightBracket; _toTokenString = ConstructorHelperBracket(leftBracket, Main, rightBracket); _toString = _toTokenString.ToString(); OriginalText = _toTokenString.ToOriginalString().Trim(); }
public MathSequence(MathToken token, Token supOrSub, Token left, MathObject math, Token right) : this(token) { if (supOrSub.Value == "^") { Sup = math; _supFirst = true; } else { Sub = math; } _toTokenString = ConstructorHelperSupSub(_toTokenString, supOrSub, left, math.ToTokenString(), right); _toString = _toTokenString.ToString(); OriginalText = _toTokenString.ToOriginalString().Trim(); }
private MathSequence(MathSequence seq, Token supOrSub, Token left, MathObject math, Token right) : this(seq) { if (supOrSub.Value == "^") { Sup = math; if (Sub == null) { _supFirst = true; } } else { Sub = math; } _toTokenString = ConstructorHelperSupSub(_toTokenString, supOrSub, left, math.ToTokenString(), right); _toString = _toTokenString.ToString(); OriginalText = _toTokenString.ToOriginalString().Trim(); }
private MathSequence(MathSequence seq, IList <MathObject> list, MathObject?sup, MathObject?sub) : this(seq) { if (list.Count == 0) { throw new InvalidOperationException($"{nameof(list)}が空です。"); } List = new ReadOnlyCollection <MathObject>(list); Main = CreateMainTokenString(List, seq.Separator); _toTokenString = ConstructorHelperBracket(seq.LeftBracket, Main, seq.RightBracket); Sup = sup; Sub = sub; if (seq._supFirst) { if (sup != null) { _toTokenString = ConstructorHelperSupSub(_toTokenString, Token.Circumflex, sup.ToTokenString()); } if (sub != null) { _toTokenString = ConstructorHelperSupSub(_toTokenString, Token.LowLine, sub.ToTokenString()); } } else { if (sub != null) { _toTokenString = ConstructorHelperSupSub(_toTokenString, Token.LowLine, sub.ToTokenString()); } if (sup != null) { _toTokenString = ConstructorHelperSupSub(_toTokenString, Token.Circumflex, sup.ToTokenString()); } } _toString = _toTokenString.ToString(); OriginalText = _toTokenString.ToOriginalString().Trim(); }