use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.
the class AbstractIntegerSym method factorInteger.
/**
* {@inheritDoc}
*/
@Override
public IASTAppendable factorInteger() {
IInteger factor;
IInteger last = F.CN2;
int count = 0;
final IAST iFactors = factorize();
IASTAppendable subList = null;
int size = iFactors.size();
final IASTAppendable list = F.ListAlloc(size);
for (int i = 1; i < size; i++) {
factor = (IInteger) iFactors.get(i);
if (!last.equals(factor)) {
if (subList != null) {
subList.append(AbstractIntegerSym.valueOf(count));
list.append(subList);
}
count = 0;
subList = F.ListAlloc(2);
subList.append(factor);
}
count++;
last = factor;
}
if (subList != null) {
subList.append(AbstractIntegerSym.valueOf(count));
list.append(subList);
}
return list;
}
use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.
the class AbstractIntegerSym method divisors.
@Override
public IAST divisors() {
if (isOne() || isMinusOne()) {
return F.CListC1;
}
Set<IInteger> set = divisorsSet();
final IASTAppendable resultList = F.ListAlloc(set.size() + 1);
for (IInteger divisor : set) {
resultList.append(divisor);
}
return resultList;
}
use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.
the class ASTSeriesData method arg3.
@Override
public final IAST arg3() {
int capacity = nMax - nMin;
if (capacity <= 0) {
capacity = 4;
}
IASTAppendable list = F.ListAlloc(capacity);
for (int i = nMin; i < nMax; i++) {
list.append(coefficient(i));
}
return list;
}
use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.
the class ASTSeriesData method toSeriesData.
public IAST toSeriesData() {
// list of coefficients
IASTAppendable coefficientList = F.ListAlloc(16);
for (int i = nMin; i < nMax; i++) {
coefficientList.append(coefficient(i));
}
IAST seriesData = F.SeriesData(x, x0, coefficientList, F.ZZ(nMin), F.ZZ(truncate), F.ZZ(denominator));
return seriesData;
}
use of org.matheclipse.core.interfaces.IASTAppendable in project symja_android_library by axkr.
the class AbstractAST method removeIf.
/**
* {@inheritDoc}
*/
@Override
public IAST removeIf(Predicate<? super IExpr> predicate) {
IASTAppendable result = F.NIL;
for (int i = 1; i < size(); i++) {
final IExpr arg = get(i);
if (predicate.test(arg)) {
continue;
}
if (!result.isPresent()) {
result = copyHead(argSize());
}
result.appendRule(arg);
}
return result.orElse(this);
}
Aggregations