// Logic thread for "for any * holds *" static class LThread2 { IEngine engine; new L statements; new SNLMatches m; // current variable assignments int opIdx; new L output; L log; new L> iterators; new L states; *(Lisp code) { this(null, code); } *(IEngine *engine, Lisp code) { assertTrue(snlMatch2("for < any < For < holds < Holds", code, m)); addIterator(getIterator("For")); } void addIterator(Iterator it) { if (it != null) { iterators.add(it); } // returns false if done boolean step() { while true { if (empty(iterators)) ret false; Iterator getIterator(S var) { Lisp term = snlApply(m.get(var), m); new SNLMatches m2; if (!snlMatch2("X < in < Y", m2)) ret null; final L list = snlParseList(Y); int state = -1; ret new Iterator() { int i = 0; public boolean hasNext() { ret i < l(list); ] public Boolean next() { m.set(m2.str("X"), list.get(i++)); ret true; } public void remove() {} }; } void say(Lisp b) { output.add(snlApply(b, m.map)); } }