package com.jedrzejewski.slisp.interpreter.primitives;

import com.jedrzejewski.slisp.lispobjects.LispObject;
import com.jedrzejewski.slisp.lispobjects.Num;
import java.util.List;

public abstract class NumPairTester extends Primitive {

    public boolean testSubsequentPairs(List<LispObject> args, DoublePairPredicate predicate) {
        double prevValue = ((Num) args.get(0)).getValue();
        for (LispObject arg : args.subList(1, args.size())) {
            double curValue = ((Num) arg).getValue();
            if (!predicate.test(prevValue, curValue)) {
                return false;
            } else {
                prevValue = curValue;
            }
        }
        return true;
    }

    public interface DoublePairPredicate {
        boolean test(double val1, double val2);
    }
}

@@ -49,16 +49,172 @@
 tives;%0A%0A
+import com.jedrzejewski.slisp.interpreter.exceptions.InterpreterException;%0Aimport com.jedrzejewski.slisp.interpreter.exceptions.WrongNumberOfArgsException;%0A
 import c
@@ -452,41 +452,145 @@
 rgs,
- DoublePairPredicate predicate) %7B
+%0A                                       DoublePairPredicate predicate)%0A            throws InterpreterException %7B%0A        validate(args);%0A
 %0A   
@@ -958,16 +958,246 @@
 %0A    %7D%0A%0A
+    public void validate(List%3CLispObject%3E args) throws InterpreterException %7B%0A        if (args.size() %3C= 1) %7B%0A            throw WrongNumberOfArgsException.atLeast(2).is(args.size());%0A        %7D%0A        // TODO: check types.%0A    %7D%0A%0A
     publ

Check no of args in comp primitives