internal override bool match(ATerm pattern, ArrayList list) { if (pattern.getType() == ATermType.LIST) { ATermList l = (ATermList)pattern; if (l.isEmpty()) { return(this.isEmpty()); } if (l.getFirst().getType() == ATermType.PLACEHOLDER) { ATerm ph_type = ((ATermPlaceholder)l.getFirst()).getPlaceholder(); if (ph_type.getType() == ATermType.APPL) { ATermAppl appl = (ATermAppl)ph_type; if (appl.getName().Equals("list") && appl.getArguments().isEmpty()) { list.Add(this); return(true); } } } if (!isEmpty()) { ArrayList submatches = first.match(l.getFirst()); if (submatches == null) { return(false); } list.AddRange(submatches); submatches = next.match(l.getNext()); if (submatches == null) { return(false); } list.AddRange(submatches); return(true); } else { return(l.isEmpty()); } } return(base.match(pattern, list)); }
public override bool equivalent(SharedObject obj) { if (base.equivalent(obj)) { ATermList peer = (ATermList)obj; if (peer.getLength() == length) { return(peer.getFirst().Equals(first) && peer.getNext().Equals(next)); } } return(false); }
public virtual ATermList reverse() { ATermList cur = this; ATermList reverse = this.getEmpty(); while (!cur.isEmpty()) { reverse = reverse.insert(cur.getFirst()); cur = cur.getNext(); } return(reverse); }
/** * Filter non-primes */ 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); }
/** * Filter non-primes */ 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)); }
public override void visitList(ATermList list) // throws VisitFailure { while (!list.isEmpty()) { visitChild(list.getFirst()); list = list.getNext(); if (!list.isEmpty()) { stream.Write(','); position++; } } }
public virtual ATermAppl makeApplList(AFun fun, ATermList list, ATermList annos) { ATerm[] arg_array; arg_array = new ATerm[list.getLength()]; int i = 0; while (!list.isEmpty()) { arg_array[i++] = list.getFirst(); list = list.getNext(); } return(makeAppl(fun, arg_array, annos)); }
public virtual ATerm dictGet(ATerm key) { if (isEmpty()) { return(null); } ATermList pair = (ATermList)first; if (key.equals(pair.getFirst())) { return(pair.getNext().getFirst()); } return(next.dictGet(key)); }
public virtual ATerm elementAt(int index) { if (0 > index || index > length) { throw new ArgumentException("illegal list index: " + index); } ATermList cur = this; for (int i = 0; i < index; i++) { cur = cur.getNext(); } return(cur.getFirst()); }
public virtual ATermAppl makeApplList(AFun fun, ATermList list, ATermList annos) { ATerm[] arg_array; arg_array = new ATerm[list.getLength()]; int i = 0; while (!list.isEmpty()) { arg_array[i++] = list.getFirst(); list = list.getNext(); } return makeAppl(fun, arg_array, annos); }