/** * Filter non-primes * * @param numbers */ private ATermList filterNonPrimes(ATermList numbers) { ATermList primes = factory.makeList(); numbers = numbers.getNext(); while (!numbers.isEmpty()) { ATermInt prime = (ATermInt) numbers.getFirst(); numbers = filterMultiples(prime.getInt(), numbers); primes = primes.append(prime); } return factory.makeList(factory.makeInt(1), primes); }
/** * Generate a list of consecutive numbers. * * @param max */ private ATermList generateNumbers(int max) { ATermList numbers = factory.makeList(); for (int i = max; i > 0; i--) numbers = factory.makeList(factory.makeInt(i), numbers); return numbers; }