public int count(){ int i = 1; for(ISeq s = next(); s != null; s = s.next(), i++) if(s instanceof Counted) return i + s.count(); return i; }
public int count(){ int i = 1; for(ISeq s = next(); s != null; s = s.next(), i++) if(s instanceof Counted) return i + s.count(); return i; }
static int countFrom(Object o){ if(o == null) return 0; else if(o instanceof IPersistentCollection) { ISeq s = seq(o); o = null; int i = 0; for(; s != null; s = s.next()) { if(s instanceof Counted) return i + s.count(); i++; } return i; } else if(o instanceof CharSequence) return ((CharSequence) o).length(); else if(o instanceof Collection) return ((Collection) o).size(); else if(o instanceof Map) return ((Map) o).size(); else if (o instanceof Map.Entry) return 2; else if(o.getClass().isArray()) return Array.getLength(o); else if(Protocol.satisfiesICount(o)) return ((Integer)Protocol.bridgeICountedCount(o)).intValue(); throw new UnsupportedOperationException("count not supported on this type: " + o.getClass().getSimpleName()); }
public Expr parse(C context, Object frm) { int line = (Integer) LINE.deref(); int column = (Integer) COLUMN.deref(); ISeq form = (ISeq) frm; //(new Classname args...) if(form.count() < 2) throw Util.runtimeException("wrong number of arguments, expecting: (new Classname args...)"); Class c = HostExpr.maybeClass(RT.second(form), false); if(c == null) throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form)); PersistentVector args = PersistentVector.EMPTY; for(ISeq s = RT.next(RT.next(form)); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); return new NewExpr(c, args, line, column); } }
public Expr parse(C context, Object frm) { int line = lineDeref(); int column = columnDeref(); ISeq form = (ISeq) frm; //(new Classname args...) if(form.count() < 2) throw Util.runtimeException("wrong number of arguments, expecting: (new Classname args...)"); Class c = HostExpr.maybeClass(RT.second(form), false); if(c == null) throw new IllegalArgumentException("Unable to resolve classname: " + RT.second(form)); PersistentVector args = PersistentVector.EMPTY; for(ISeq s = RT.next(RT.next(form)); s != null; s = s.next()) args = args.cons(analyze(context == C.EVAL ? context : C.EXPRESSION, s.first())); return new NewExpr(c, args, line, column); } }
public Expr parse(C context, Object frm) { ISeq form = (ISeq) frm; if(form.count() > 4) throw Util.runtimeException("Too many arguments to if"); else if(form.count() < 3) throw Util.runtimeException("Too few arguments to if"); PathNode branch = new PathNode(PATHTYPE.BRANCH, (PathNode) CLEAR_PATH.get());
private static Expression analyseSeq(Environment env, ISeq form) { int n=form.count(); if (n==0) return Constant.create(form); Object first=form.first();