Always(final Function<Object, ? extends T> s) { super(TreePVector.singleton(Rec.raw(s))); }
/** * Construct a PVector containing a single value * </pre> * {@code * List<String> single = PVectors.singleton("1"); * * //or * * PVector<String> single = PVectors.singleton("1"); * * } * </pre> * * @param value Single value for PVector * @return PVector with a single value */ public static <T> PVector<T> singleton(T value){ return TreePVector.singleton(value); } /**
UtilityTest.assertEqualsAndHash(TreePVector.empty(), pvec.minusAll(pvec)); UtilityTest.assertEqualsAndHash(pvec, TreePVector.empty().plusAll(pvec)); UtilityTest.assertEqualsAndHash(pvec, TreePVector.singleton(10).plusAll(1,pvec).minus(0));
@Override public PSequence<MessageProtocol> acceptResponseProtocols() { return TreePVector.singleton(new MessageProtocol(Optional.of("application/json"), Optional.empty(), Optional.empty())); }
@Override public PSequence<MessageProtocol> acceptResponseProtocols() { return TreePVector.singleton(new MessageProtocol(Optional.of("application/json"), Optional.empty(), Optional .empty())); }
size0 = pseq.size(); inBounds = j>=0 && j<=pseq.size(); pseq = pseq.plusAll(j, TreePVector.singleton(r.nextInt())); if (!inBounds) fail(); } catch (IndexOutOfBoundsException e) {
Later(final Function<Object, ? extends T> s) { super(TreePVector.singleton(Rec.raw(Memoize.memoizeFunction(s)))); }
default PVector<Function<Object, Object>> steps() { return TreePVector.singleton(__ -> get()); }
/** * Construct a PVector containing a single value * </pre> * {@code * List<String> single = PVectors.singleton("1"); * * //or * * PVector<String> single = PVectors.singleton("1"); * * } * </pre> * * @param value Single value for PVector * @return PVector with a single value */ public static <T> PVectorX<T> singleton(T value){ return new PVectorXImpl<>(TreePVector.singleton(value)); } /**
/** * Construct a PVector containing a singleUnsafe value * </pre> * {@code * List<String> singleUnsafe = PVectors.singleton("1"); * * //or * * PVector<String> singleUnsafe = PVectors.singleton("1"); * * } * </pre> * * @param value Active value for PVector * @return PVector with a singleUnsafe value */ public static <T> VectorX<T> singleton(final T value) { return new LazyPVectorX<>( TreePVector.singleton(value),null,Reducers.toPVector(), LAZY); }
@Override public <R> Eval<R> flatMap(final Function<? super T, ? extends MonadicValue<? extends R>> mapper) { final RecFunction s = __ -> asEval(mapper.apply(apply())).steps(); return new Always<R>( TreePVector.singleton(s)); }
@Override public <R> Eval<R> flatMap(final Function<? super T, ? extends MonadicValue<? extends R>> mapper) { final RecFunction s = __ -> asEval(mapper.apply(super.applyRec())).steps(); return new Later<R>(TreePVector.singleton(s)); }
public static <T> Monoid<PVector<T>> toPVector() { return Monoid.<PVector<T>>of(TreePVector .empty(), (PVector<T> a) -> b -> a.plusAll(b), (T x) -> TreePVector.singleton(x)); } public static <T> Monoid<PStack<T>> toPStack() {
/** * <pre> * {@code * PVector<Integer> q = Reducers.<Integer>toPVector() .mapReduce(Stream.of(1,2,3,4)); * * } * </pre> * @return Reducer for PVector */ public static <T> Reducer<PVector<T>> toPVector() { return Reducer.<PVector<T>> of(TreePVector.empty(), (final PVector<T> a) -> b -> a.plusAll(b), (final T x) -> TreePVector.singleton(x)); } /**