本文整理汇总了Java中fj.data.Stream.cons方法的典型用法代码示例。如果您正苦于以下问题:Java Stream.cons方法的具体用法?Java Stream.cons怎么用?Java Stream.cons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fj.data.Stream
的用法示例。
在下文中一共展示了Stream.cons方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromIterator
import fj.data.Stream; //导入方法依赖的package包/类
public static final <A> Stream<A> fromIterator(final Iterator<A> iterator) {
if (!iterator.hasNext())
return nil();
return Stream.cons(iterator.next(), new P1<Stream<A>>() {
@Override
public Stream<A> _1() {
return fromIterator(iterator);
}
});
}
示例2: sequenceW
import fj.data.Stream; //导入方法依赖的package包/类
/**
* Applies a stream of comonadic functions to this promise, returning a stream of values.
*
* @param fs A stream of functions to apply to this promise.
* @return A stream of the results of applying the given stream of functions to this promise.
*/
public <B> Stream<B> sequenceW(final Stream<F<Promise<A>, B>> fs) {
return fs.isEmpty()
? Stream.<B>nil()
: Stream.cons(fs.head().f(this), new P1<Stream<B>>() {
public Stream<B> _1() {
return sequenceW(fs.tail()._1());
}
});
}
示例3: toStream
import fj.data.Stream; //导入方法依赖的package包/类
/**
* Returns a stream of the elements of this vector.
*
* @return a stream of the elements of this vector.
*/
public Stream<A> toStream() {
return Stream.cons(head._1(), new P1<Stream<A>>() {
public Stream<A> _1() {
return tail.toStream();
}
});
}
示例4: toStream
import fj.data.Stream; //导入方法依赖的package包/类
/**
* Returns a stream of the elements of this vector.
*
* @return a stream of the elements of this vector.
*/
public Stream<A> toStream() {
return Stream.cons(_1(), new P1<Stream<A>>() {
public Stream<A> _1() {
return Stream.single(_2());
}
});
}
示例5: toStream
import fj.data.Stream; //导入方法依赖的package包/类
/**
* Returns a stream of the elements of this vector.
*
* @return a stream of the elements of this vector.
*/
public Stream<A> toStream() {
return Stream.cons(head()._1(), new P1<Stream<A>>() {
public Stream<A> _1() {
return tail().toStream();
}
});
}