Package clojure.lang

Examples of clojure.lang.ISeq


        for (int i = 0; i < total; i += 2) {
            String k = (String) arrays[i];
            Object v = arrays[i + 1];
            // ring spec says it could be a seq
            if (v instanceof Seqable) {
                ISeq seq = ((Seqable) v).seq();
                while (seq != null) {
                    bytes.append(k);
                    bytes.append(COLON, SP);
                    bytes.append(seq.first().toString(), HttpUtils.UTF_8);
                    bytes.append(CR, LF);
                    seq = seq.next();
                }
            } else {
                bytes.append(k);
                bytes.append(COLON, SP);
                // supposed to be ISO-8859-1, but utf-8 is compatible.
View Full Code Here


            return ByteBuffer.wrap(b.get(), 0, b.length());
        } else if (body instanceof File) {
            // serving file is better be done by Nginx
            return readAll((File) body);
        } else if (body instanceof Seqable) {
            ISeq seq = ((Seqable) body).seq();
            DynamicBytes b = new DynamicBytes(seq.count() * 512);
            while (seq != null) {
                b.append(seq.first().toString(), UTF_8);
                seq = seq.next();
            }
            return ByteBuffer.wrap(b.get(), 0, b.length());
            // makes ultimate optimization possible: no copy
        } else if (body instanceof ByteBuffer) {
            return (ByteBuffer) body;
View Full Code Here

  @Override
  public Object applyTo(ISeq arglist) {
    if (arglist==null) throw new ArityException(0,"VectorFunctsion requires exactly one argument");
    Object o=arglist.first();
    ISeq next=arglist.next();
    if (next!=null) throw new ArityException(RT.count(arglist),"VectorFunctsion requires exactly one argument");
    return invoke(o);
  }
View Full Code Here

  }
 
  @Override
  public Type intersection(Type t) {
    PersistentHashSet values=this.values;
    ISeq s=values.seq();
    while(s!=null) {
      Object o=s.first();
      if (!t.checkInstance(o)) {
        values=(PersistentHashSet) values.disjoin(o);
      }
      s=s.next();
    }
    return update(values);
  }
View Full Code Here

  @Test
  public void testIf() {
    assertEquals(2,If.create(Constant.create(null), Constant.create(1), Constant.create(2)).eval());
   
    ISeq s=KissUtils.createSeq(Symbol.intern("if"),Symbol.intern("nil"),1,2);
    Expression x=Analyser.analyse(s);
    assertEquals(2,x.eval());

  }
View Full Code Here

      IFn macroFn=(IFn) fn.eval(Environment.EMPTY);
      Object expandedForm=macroFn.applyTo(RT.cons(form,RT.cons(PersistentHashMap.EMPTY, form.next())));
      return analyse(expandedForm);
    }
   
    ISeq paramSeq=RT.next(form);
    int paramCount=RT.count(paramSeq);
    Expression[] params=new Expression[paramCount];
    int i=0;
    for (ISeq s=RT.seq(paramSeq); s!=null; s=s.next()) {
      params[i++]=analyse(s.first());
View Full Code Here


        public Matrix(Seqable coll, int rows, int columns) {
                super(rows, columns);
                this.meta = null;
                ISeq seq = coll.seq();
                for(int i = 0; i < (rows); i++) {
                        for(int j = 0; j < (columns); j++) {
                                this.set(i, j, ((Number)(seq.first())).doubleValue());
                                seq = seq.next();
                        }
                }
        }
View Full Code Here

                        return new Matrix(this.rows-1, this.columns, subset, false);
                }
        }

        public ISeq more() {
                ISeq result = this.next();
                if(result != null)
                        return result;
                else
                        return new Matrix(0, 0, 0);
        }
View Full Code Here

                                        newData[this.rows + i][j] = m.getQuick(i, j);

                        return(new Matrix(newData));
                }
                else if(o instanceof Seqable) {
                        ISeq v = ((Seqable)o).seq();
                        double[][] newData = new double[this.rows + 1][this.columns];
                        for(int i = 0; i < (this.rows); i++)
                                for(int j = 0; j < (this.columns); j++)
                                        newData[i][j] = this.getQuick(i, j);
                        ISeq restObj = v;
                        int cols = 0;
                        while(cols < this.columns) {
                                newData[this.rows][cols] = ((Number)(restObj.first())).doubleValue();
                                restObj = restObj.next();
                                cols++;
                        }

                        return(new Matrix(newData));
                }
View Full Code Here

    /**
     * BE CAREFUL: this is a blocking method, waiting for the full
     * nrepl response to come back !
     */
    private boolean hasEvalResponseException(Object evalResponse) {
      ISeq responseSeq = (ISeq) evalResponse;
      while (responseSeq != null) {
        Map<?,?> m = (Map<?,?>) responseSeq.first();
        if (m.containsKey(errorResponseKey)) {
          return true;
        }
        responseSeq = responseSeq.next();
      }
      return false;
    }
View Full Code Here

TOP

Related Classes of clojure.lang.ISeq

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.