This commit is contained in:
2020-07-27 22:54:49 +03:00
parent 57c2a763fa
commit 1706dac114

View File

@@ -48,6 +48,11 @@ namespace MatrixExtensions
FunctionSections.MatricesAndVectors, true, FunctionSections.MatricesAndVectors, true,
new ArgumentInfo(ArgumentSections.Matrix)), new ArgumentInfo(ArgumentSections.Matrix)),
new TermInfo("listSortAsText", TermType.Function,
"Возвращает сортированный вектор значений, содержащихся в ('матрица').",
FunctionSections.MatricesAndVectors, true,
new ArgumentInfo(ArgumentSections.Matrix)),
new TermInfo("listLength", TermType.Function, new TermInfo("listLength", TermType.Function,
"Возвращает длину вектора ('вектор').", "Возвращает длину вектора ('вектор').",
FunctionSections.MatricesAndVectors, true, FunctionSections.MatricesAndVectors, true,
@@ -156,6 +161,32 @@ namespace MatrixExtensions
return true; return true;
} }
//listSort
if (value.Type == TermType.Function && value.ArgsCount == 1 && value.Text == "listSortAsText")
{
Entry arg1 = Computation.Preprocessing(value.Items[0], context);
TNumber tmp = Computation.NumericCalculation(arg1, context);
List<string> vector = new List<string>(Utilites.EntryMatrix2ArrStr(tmp.obj));
vector.RemoveAt(vector.Count - 1);
vector.RemoveAt(vector.Count - 1);
vector.Sort();
List<Term> answer = new List<Term>();
foreach (string item in vector)
{
answer.AddRange(TermsConverter.ToTerms(item));
}
answer.AddRange(TermsConverter.ToTerms(vector.Count.ToString()));
answer.AddRange(TermsConverter.ToTerms(1.ToString()));
answer.Add(new Term(Functions.Mat, TermType.Function, 2 + vector.Count));
result = Entry.Create(answer.ToArray());
return true;
}
//listAdd //listAdd
if (value.Type == TermType.Function && value.ArgsCount == 2 && value.Text == "listAdd") if (value.Type == TermType.Function && value.ArgsCount == 2 && value.Text == "listAdd")
{ {