package yukicoder_9568; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; import java.util.BitSet; import java.util.HashSet; import java.util.NoSuchElementException; public class Main { public static void main(String[] args) { new Main(); } public Main() { InputChecker ic = new InputChecker(System.in); java.io.PrintWriter out = new java.io.PrintWriter(System.out); solve(ic, out); out.flush(); } /* * 命題変数の真偽を一つ固定する。 * この時、どの命題についてもその命題が真か偽かは確定する。 * 命題をfとすると、f(P0, …, P5)=命題の真偽、という形 * * さて、この時に各演算がどのように作用するか考える。 * OYが確定していることから、ある関数g_{Ox}(f)が存在して、g_{Ox}(f) = fOxとなる * f, xの真偽は0と1の二通りだから、g_{Ox}は2次元ベクトルとなり、このようなものは4状態しか取らないね * ところで変換行列ってモノイドで、合成可能ですね */ enum Operator { LAND, LOR, RIGHTARROW; /** * 命題と論理演算から定まる作用関数を返します。 * @param Y この時点でのX_hの値 * @return 作用関数 */ BitFunction getFunction(long val) { switch(this) { case LAND: return BitFunction.and(val); case LOR: return BitFunction.or(val); case RIGHTARROW: return BitFunction.imply(val); } throw new AssertionError(); } static Operator getOperator(String operator) { switch(operator) { case "land": return Operator.LAND; case "lor": return Operator.LOR; case "Rightarrow": return Operator.RIGHTARROW; } throw new AssertionError(); } } class Query { int h; Operator o; int l, r, l2, r2; Query(InputChecker ic, int N) { h = ic.nextInt(0, N - 1); ic.nextChar(' '); o = Operator.getOperator(ic.next(CharSet.ALPHABET)); ic.nextChar(' '); l = ic.nextInt(0, N - 1); ic.nextChar(' '); r = ic.nextInt(l, N - 1) + 1; ic.nextChar(' '); l2 = ic.nextInt(0, N - 1); ic.nextChar(' '); r2 = ic.nextInt(l2, N - 1) + 1; if (r2 - l2 > 1000) throw new AssertionError(); ic.readNewLine(); } } /* * 基本方針 * 1. 全体の命題変数の真偽をそれぞれ固定し、その場合の真偽を解く * 従って、同じ問題を2^6 = 64回解くことになる * * 命題変数が決め打たれている時、真偽も分かるので0,1の2状態のみ管理すれば良い * すると、問題は以下の様に考えることができる * * 0,1で表された長さNの配列が与えられます * 以下のクエリを捌いてください * 1. X_hの値を取得し、X_h及び追加で与えられた文字列oに応じてどれかの区間作用が発生する * ・区間を0にする * ・区間を1にする * ・区間を反転する * 2. 区間のそれぞれの0,1の値を取得する、長さは最大でL * * さて、区間作用1点取得のクエリをO(A)/O(B)で捌けるとすると、計算量はクエリごとにO(A+LB) * また、区間作用1点取得といえばセグ木や平方分割が有名だが、セグ木だとO(LlogN)、平方分割だとO(L+√N) * ここでLは√Nより大きい(10^3)から、平方分割を書いた方が得か * * 作用だが、作用行列を考えれば4状態あれば十分であることが分かる * 0の時にxを返す、1の時にyを返すを持った行列(x, y)に対して作用を考えると、全部作用行列になるので * (0, 0)=0, (0, 1)=e, (1, 0)=~, (1, 1)=1として表す * この時、左辺を左、右辺を上に書く行列だと以下の様になる * \ 0 1 e ~ * 0 0 0 0 0 * 1 1 1 1 1 * e 0 1 e ~ * ~ 1 0 ~ e * さて、これを良い感じにエンコードしたい * * この方針だとTLEするか……ちゃんと64並列で解こうね * * ということで、ちゃんとand, or, notを解く * xに対して作用する関数f_{a, b}=(x&a)^bを定義 * この時、結果は以下の様になる * (0, 0)→0 * (0, 1)→1 * (1, 0)→x * (1, 1)→!x * つまり、全てのパターンを網羅している * g_{c, d}∘f_{a, b} = h_{a&c, (b&c)^d}で合成関数も定義できるので勝ち */ public void solve(InputChecker ic, java.io.PrintWriter out) { int N = ic.nextInt(1, 1_000_000); ic.nextChar(' '); int Q = ic.nextInt(1, 10_000); ic.readNewLine(); Query[] query = new Query[Q]; for (int i = 0;i < Q;++ i) query[i] = new Query(ic, N); ic.checkEOF(); BitSet ans = solve(N, query); for (int i = 0;i < Q;++ i) { out.println(ans.get(i) ? "Yes" : "No"); } } static final int c = 6; // 命題変数の種類 /** * 命題変数の真偽をPを用いて定めた時の結果をqueryに格納します。 * @param N 配列長 * @param query クエリ * @return 答えを格納したBitSet */ BitSet solve(int N, Query[] query) { LongDualSqrtDecomposition X; { long[] x = new long[N]; long[] test = new long[c]; for (int i = 0;i < c;++ i) { for (int j = 0;j < 64;++ j) if ((j >> i & 1) != 0) test[i] |= 1L << j; } for (int i = 0;i < N;++ i) x[i] = test[i % c]; X = LongDualSqrtDecomposition.create(x, BitFunction.composition()); } BitSet result = new BitSet(query.length); for (int i = 0;i < query.length;++ i) { Query q = query[i]; BitFunction operator = q.o.getFunction(X.get(q.h)); // 今回の演算 X.apply(q.l, q.r, operator); HashSet set = new HashSet<>(q.r2 - q.l2, 1); X.foreach(q.l2, q.r2, (j, v) -> set.add(v)); result.set(i, set.size() != q.r2 - q.l2); } return result; } public static int exponent10(int n, int e) { return n * pow(10, e); } public static long exponent10L(int n, int e) { return n * pow(10L, e); } public static int pow(int a, int b) { int ans = 1; for (int mul = a;b > 0;b >>= 1, mul *= mul) if ((b & 1) != 0) ans *= mul; return ans; } public static long pow(long a, long b) { long ans = 1; for (long mul = a;b > 0;b >>= 1, mul *= mul) if ((b & 1) != 0) ans *= mul; return ans; } public static class CharSet { private final BitSet set = new BitSet(256); public void add(char... c) { for (char i : c) set.set(i); } public void add(CharSet... s) { for (CharSet i : s) set.or(i.set); } public boolean contains(char... c) { for (char i : c) if (!set.get(i)) return false; return true; } public boolean contains(String s) { return contains(s.toCharArray()); } private static final class Chars extends CharSet { public Chars(char... c) { super.add(c); } public Chars(CharSet... s) { super.add(s); } @Override public void add(char... c) { throw new UnsupportedOperationException(); } @Override public void add(CharSet... s) { throw new UnsupportedOperationException(); } } public static final CharSet NUMBER = new Chars('0','1','2','3','4','5','6','7','8','9'); public static final CharSet LOWER = new Chars('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); public static final CharSet UPPER = new Chars('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); public static final CharSet ALPHABET = new Chars(LOWER, UPPER); } public static class InputChecker { private InputStream in; private final byte[] buffer = new byte[1024]; private final byte[] undo = new byte[1024]; private int undoSize = 0; private int read = 0; private int length = 0; public InputChecker(InputStream in) { this.in = in; } public final void setInputStream(InputStream in) { this.in = in; } public final void setInputStream(File in) { try { this.in = new FileInputStream(in); } catch (FileNotFoundException e) { e.printStackTrace(); } } private boolean hasNextByte() { if (undoSize > 0) return true; if (read < length) return true; read = 0; try { length = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } return length > 0; } private byte readByte() { if (hasNextByte()) return undoSize > 0 ? undo[--undoSize] : buffer[read++]; throw new NoSuchElementException(); } private void undo(byte b) { undo[undoSize ++] = b; } private void undo(char c) { if ((c & 0xFF80) == 0) { undo((byte)c); return; } undo((byte)(c & 0x3F | 0x80)); if ((c & 0xF800) == 0) { undo((byte)(c >> 6 & 0x1F | 0xC0)); } else { undo((byte)(c >> 6 & 0x3F | 0x80)); undo((byte)(c >> 12 | 0xE0)); } } public final boolean hasNext() { return hasNextByte(); } public final char nextChar() { byte b = readByte(); if ((b & 0x80) == 0) return (char)b; if ((b & 0x20) == 0) return (char)((b & 0x1F) << 6 | readByte() & 0x3F); return (char)((b & 0xF) << 12 | (readByte() & 0x3F) << 6 | readByte() & 0x3F); } public final char nextChar(char estimate) { char c = nextChar(); if (estimate == c) return estimate; undo(c); throw new AssertionError(); } public final char nextChar(CharSet estimate) { char c = nextChar(); if (estimate.contains(c)) return c; undo(c); throw new AssertionError(); } public final void readNewLine() { char c = nextChar(); if (c == '\r') { c = nextChar(); if (c != '\n') undo(c); return; } else if (c == '\n') return; undo(c); throw new AssertionError(); } public final void checkEOF() { if (hasNextByte()) throw new AssertionError(); } public final String next(CharSet contains) { StringBuilder sb = new StringBuilder(); try { do { char c = nextChar(); if (!contains.contains(c)) { undo(c); return sb.toString(); } sb.append(c); } while(true); } catch (NoSuchElementException e) { if (sb.length() <= 0) throw new AssertionError(); return sb.toString(); } } public final int nextInt() { byte b = readByte(); int n = 0; if (b == '-') { if (!isNumber(b = readByte())) { undo(b); throw new NumberFormatException(); } try { if (b == '0') { if (!isNumber(b = readByte())) { undo(b); return 0; } throw new NumberFormatException(); } do n = Math.addExact(Math.multiplyExact(n, 10), '0' - b); while(isNumber(b = readByte())); undo(b); } catch (NoSuchElementException e) { } return n; } if (!isNumber(b)) { undo(b); throw new NumberFormatException(); } try { if (b == '0') { if (!isNumber(b = readByte())) { undo(b); return 0; } throw new NumberFormatException(); } do n = Math.addExact(Math.multiplyExact(n, 10), b - '0'); while(isNumber(b = readByte())); undo(b); } catch (NoSuchElementException e) { } return n; } public final int nextInt(int min, int max) { int n = nextInt(); if (min <= n && n <= max) return n; throw new NumberFormatException(); } private static boolean isNumber(byte c) { return '0' <= c && c <= '9'; } public final long nextLong() { byte b = readByte(); long n = 0; if (b == '-') { if (!isNumber(b = readByte())) { undo(b); throw new NumberFormatException(); } try { if (b == '0') { if (!isNumber(b = readByte())) { undo(b); return 0; } throw new NumberFormatException(); } do n = Math.addExact(Math.multiplyExact(n, 10), '0' - b); while(isNumber(b = readByte())); undo(b); } catch (NoSuchElementException e) { } return n; } if (!isNumber(b)) { undo(b); throw new NumberFormatException(); } try { if (b == '0') { if (!isNumber(b = readByte())) { undo(b); return 0; } throw new NumberFormatException(); } do n = Math.addExact(Math.multiplyExact(n, 10), b - '0'); while(isNumber(b = readByte())); undo(b); } catch (NoSuchElementException e) { } return n; } public final long nextLong(long min, long max) { long n = nextLong(); if (min <= n && n <= max) return n; throw new NumberFormatException(); } public final double nextDouble() { StringBuilder sb = new StringBuilder(); byte b = readByte(); if (b == '-') { sb.append(b); b = readByte(); } if (b == '0') { sb.append(b); b = readByte(); } else { while(isNumber(b)) { sb.append(b); b = readByte(); } } if (b == '.') { sb.append(b); b = readByte(); while(isNumber(b)) { sb.append(b); b = readByte(); } } if (b == 'e' || b == 'E') { sb.append(b); b = readByte(); if (b == '-' || b == '+') { sb.append(b); b = readByte(); } while(isNumber(b)) { sb.append(b); b = readByte(); } } undo(b); return Double.parseDouble(sb.toString()); } } } class BitFunction implements LongEndoMorphism { final long and, xor; private BitFunction(long and, long xor) { this.and = and; this.xor = xor; } @Override public long applyAsLong(long operand) { return operand & and ^ xor; } public BitFunction andThen(BitFunction after) { return new BitFunction(and & after.and, xor & after.and ^ after.xor); } public BitFunction compose(BitFunction before) { return new BitFunction(before.and & and, before.xor & and ^ xor); } public static BitFunction identity() { return new BitFunction(-1L, 0L); } public static Monoid composition() { return new Monoid() { @Override public BitFunction apply(BitFunction t, BitFunction u) { return u.andThen(t); } @Override public BitFunction identity() { return BitFunction.identity(); } }; } public static BitFunction and(long and) { return new BitFunction(and, 0L); } public static BitFunction xor(long xor) { return new BitFunction(-1L, xor); } public static BitFunction or(long or) { return new BitFunction(~or, or); } public static BitFunction not() { return new BitFunction(-1L, -1L); } public static BitFunction nand(long and) { return new BitFunction(and, -1L); } public static BitFunction nor(long or) { return new BitFunction(~or, ~or); } public static BitFunction imply(long consequent) { return new BitFunction(~consequent, -1L); } public static BitFunction xnor(long xor) { return new BitFunction(-1L, ~xor); } } class LongDualSqrtDecomposition { private final Monoid composition; private final int bucket; private final Object[] top; private final long[] bottom; private final M identity; LongDualSqrtDecomposition(long[] array, Monoid composition, int bucket) { this.composition = composition; identity = composition.identity(); bottom = array.clone(); top = new Object[array.length / bucket]; Arrays.fill(top, identity); this.bucket = bucket; } @SuppressWarnings("unchecked") private M getTop(int index) { return (M) top[index]; } private void lazy(int topIndex) { if (0 > topIndex || topIndex >= top.length) return; M apply = getTop(topIndex); top[topIndex] = identity; for (int l = topIndex * bucket, r = l + bucket;l < r;++ l) bottom[l] = apply.applyAsLong(bottom[l]); } public void apply(int p, M f) { lazy(p / bucket); bottom[p] = f.applyAsLong(bottom[p]); } public void apply(int l, int r, M f) { int lTop = (l + bucket - 1) / bucket; int rTop = r / bucket; if (lTop >= rTop) { if (lTop == rTop) lazy(lTop - 1); lazy(rTop); for (int i = l;i < r;++ i) bottom[i] = f.applyAsLong(bottom[i]); return; } int rBottom = lTop * bucket; int lBottom = rTop * bucket; lazy(lTop - 1); lazy(rTop); for (int i = l;i < rBottom;++ i) bottom[i] = f.applyAsLong(bottom[i]); for (int i = lBottom;i < r;++ i) bottom[i] = f.applyAsLong(bottom[i]); for (int i = lTop;i < rTop;++ i) top[i] = composition.apply(f, getTop(i)); } public void set(int p, long val) { lazy(p / bucket); bottom[p] = val; } public long get(int p) { lazy(p / bucket); return bottom[p]; } public long[] get(int l, int r) { int lTop = l / bucket; int rTop = (r + bucket - 1) / bucket; for (int i = lTop;i < rTop;++ i) lazy(i); return Arrays.copyOfRange(bottom, l, r); } public void foreach(int l, int r, LongIndexableConsumer action) { int lTop = l / bucket; int rTop = (r + bucket - 1) / bucket; for (int i = lTop;i < rTop;++ i) lazy(i); for (int i = l;i < r;++ i) action.accept(i, bottom[i]); } public static LongDualSqrtDecomposition create(long[] array, Monoid composition, int bucket) { return new LongDualSqrtDecomposition<>(array, composition, bucket); } public static LongDualSqrtDecomposition create(long[] array, Monoid composition) { return new LongDualSqrtDecomposition<>(array, composition, (int)Math.max(1, Math.sqrt(array.length))); } } interface IndexableConsumer { public void accept(int index, E value); } interface IntIndexableConsumer extends IndexableConsumer { public void acceptAsInt(int index, int value); @Override public default void accept(int index, Integer value) { acceptAsInt(index, value); } } interface LongIndexableConsumer extends IndexableConsumer { public void acceptAsLong(int index, long value); @Override public default void accept(int index, Long value) { acceptAsLong(index, value); } } interface DoubleIndexableConsumer extends IndexableConsumer { public void acceptAsDouble(int index, double value); @Override public default void accept(int index, Double value) { acceptAsDouble(index, value); } } interface LongMonoid extends Monoid, LongAssociative, LongUnital { @Override public default long hyperAsLong(long element, int repeat) { if (repeat < 0) throw new IllegalArgumentException("undefined operation"); long ret = identityAsLong(); for (long mul = element;repeat > 0;repeat >>= 1, mul = applyAsLong(mul, mul)) if ((repeat & 1) != 0) ret = applyAsLong(ret, mul); return ret; } @Override public default long hyperAsLong(long element, long repeat) { if (repeat < 0) throw new IllegalArgumentException("undefined operation"); long ret = identityAsLong(); for (long mul = element;repeat > 0;repeat >>= 1, mul = applyAsLong(mul, mul)) if ((repeat & 1) != 0) ret = applyAsLong(ret, mul); return ret; } @Override default Long hyper(Long element, int repeat) { return hyperAsLong(element, repeat); } @Override default Long hyper(Long element, long repeat) { return hyperAsLong(element, repeat); } } interface LongEndoMorphism extends LongMorphism, EndoMorphism, java.util.function.LongUnaryOperator { @Override public default Long apply(Long operand) { return applyAsLong((long) operand); } @Override public default Long apply(long operand) { return applyAsLong(operand); } @Override public default long applyAsLong(Long operand) { return applyAsLong((long) operand); } public default LongEndoMorphism andThen(LongEndoMorphism after) { return s -> after.applyAsLong(applyAsLong(s)); } public default LongEndoMorphism compose(LongEndoMorphism before) { return s -> applyAsLong(before.applyAsLong(s)); } public static LongEndoMorphism identity() { return t -> t; } public static Monoid composition() { return new Monoid() { @Override public LongEndoMorphism apply(LongEndoMorphism t, LongEndoMorphism u) { return u.andThen(t); } @Override public LongEndoMorphism identity() { return LongEndoMorphism.identity(); } }; } } interface Monoid extends Associative, Unital { @Override public default T hyper(T element, int repeat) { if (repeat < 0) throw new IllegalArgumentException("undefined operation"); T ret = identity(); for (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul); return ret; } @Override public default T hyper(T element, long repeat) { if (repeat < 0) throw new IllegalArgumentException("undefined operation"); T ret = identity(); for (T mul = element;repeat > 0;repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul); return ret; } } interface LongAssociative extends Associative, LongMagma{ @Override public default Long apply(Long t, Long u) { return applyAsLong(t, u); } @Override public default Long hyper(Long element, int repeat) { return hyperAsLong(element, repeat); } @Override public default Long hyper(Long element, long repeat) { return hyperAsLong(element, repeat); } public default long hyperAsLong(long element, int repeat) { if (repeat < 1) throw new IllegalArgumentException("undefined operation"); long ret = element; -- repeat; for (long mul = element;repeat > 0;repeat >>= 1, mul = applyAsLong(mul, mul)) if ((repeat & 1) != 0) ret = applyAsLong(ret, mul); return ret; } public default long hyperAsLong(long element, long repeat) { if (repeat < 1) throw new IllegalArgumentException("undefined operation"); long ret = element; -- repeat; for (long mul = element;repeat > 0;repeat >>= 1, mul = applyAsLong(mul, mul)) if ((repeat & 1) != 0) ret = applyAsLong(ret, mul); return ret; } } interface LongUnital extends Unital, LongMagma { @Override public default Long identity() { return identityAsLong(); } public long identityAsLong(); } interface EndoMorphism extends Morphism, java.util.function.UnaryOperator { public default EndoMorphism andThen(EndoMorphism after) { return s -> after.apply(apply(s)); } public default EndoMorphism compose(EndoMorphism before) { return s -> apply(before.apply(s)); } public static EndoMorphism identity() { return t -> t; } public static Monoid> composition() { return new Monoid>() { @Override public EndoMorphism apply(EndoMorphism t, EndoMorphism u) { return u.andThen(t); } @Override public EndoMorphism identity() { return EndoMorphism.identity(); } }; } } interface LongMorphism extends LongToObjMorphism, ObjToLongMorphism, java.util.function.LongUnaryOperator { @Override public default Long apply(Long operand) { return applyAsLong((long) operand); } @Override public default Long apply(long operand) { return applyAsLong(operand); } @Override public default long applyAsLong(Long operand) { return applyAsLong((long) operand); } @Override public default LongToIntMorphism andThen(java.util.function.LongToIntFunction after) { return s -> after.applyAsInt(applyAsLong(s)); } @Override public default LongMorphism andThen(java.util.function.LongUnaryOperator after) { return s -> after.applyAsLong(applyAsLong(s)); } public default LongMorphism andThen(LongMorphism after) { return s -> after.applyAsLong(applyAsLong(s)); } @Override public default LongToDoubleMorphism andThen(java.util.function.LongToDoubleFunction after) { return s -> after.applyAsDouble(applyAsLong(s)); } @Override public default LongToObjMorphism andThen(java.util.function.LongFunction after) { return s -> after.apply(applyAsLong(s)); } @Override public default IntToLongMorphism compose(java.util.function.IntToLongFunction before) { return s -> applyAsLong(before.applyAsLong(s)); } @Override public default LongMorphism compose(java.util.function.LongUnaryOperator before) { return s -> applyAsLong(before.applyAsLong(s)); } public default LongMorphism compose(LongMorphism before) { return s -> applyAsLong(before.applyAsLong(s)); } @Override public default DoubleToLongMorphism compose(java.util.function.DoubleToLongFunction before) { return s -> applyAsLong(before.applyAsLong(s)); } @Override public default ObjToLongMorphism compose(java.util.function.ToLongFunction before) { return s -> applyAsLong(before.applyAsLong(s)); } public static Associative composition() { return (t, u) -> t.andThen(u); } } interface Associative extends Magma { public default T hyper(T element, int repeat) { if (repeat < 1) throw new IllegalArgumentException("undefined operation"); T ret = element; --repeat; for (T mul = element; repeat > 0; repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul); return ret; } public default T hyper(T element, long repeat) { if (repeat < 1) throw new IllegalArgumentException("undefined operation"); T ret = element; --repeat; for (T mul = element; repeat > 0; repeat >>= 1, mul = apply(mul, mul)) if ((repeat & 1) != 0) ret = apply(ret, mul); return ret; } } interface Unital extends Magma { public T identity(); } interface LongMagma extends Magma, java.util.function.LongBinaryOperator { @Override public default EndoMorphism partial(Long bind) { return partialAsLong(bind); } public default LongEndoMorphism partialAsLong(long bind) { return t -> applyAsLong(bind, t); } } interface Morphism extends java.util.function.Function{ @Override public default Morphism andThen(java.util.function.Function after) { return s -> after.apply(apply(s)); } @Override public default Morphism compose(java.util.function.Function before) { return s -> apply(before.apply(s)); } public static Associative> composition() { return (t, u) -> t.andThen(u); } } interface LongToObjMorphism extends Morphism, java.util.function.LongFunction { @Override public default T apply(Long operand) { return apply((long) operand); } public default LongToIntMorphism andThen(java.util.function.ToIntFunction after) { return s -> after.applyAsInt(apply(s)); } public default LongMorphism andThen(java.util.function.ToLongFunction after) { return s -> after.applyAsLong(apply(s)); } public default LongToDoubleMorphism andThen(java.util.function.ToDoubleFunction after) { return s -> after.applyAsDouble(apply(s)); } @Override public default LongToObjMorphism andThen(java.util.function.Function after) { return s -> after.apply(apply(s)); } public default IntToObjMorphism compose(java.util.function.IntToLongFunction before) { return s -> apply(before.applyAsLong(s)); } public default LongToObjMorphism compose(java.util.function.LongUnaryOperator before) { return s -> apply(before.applyAsLong(s)); } public default DoubleToObjMorphism compose(java.util.function.DoubleToLongFunction before) { return s -> apply(before.applyAsLong(s)); } public default Morphism compose(java.util.function.ToLongFunction before) { return s -> apply(before.applyAsLong(s)); } } interface ObjToLongMorphism extends Morphism, java.util.function.ToLongFunction { @Override public default Long apply(S operand) { return applyAsLong(operand); } public default ObjToIntMorphism andThen(java.util.function.LongToIntFunction after) { return s -> after.applyAsInt(applyAsLong(s)); } public default ObjToLongMorphism andThen(java.util.function.LongUnaryOperator after) { return s -> after.applyAsLong(applyAsLong(s)); } public default ObjToDoubleMorphism andThen(java.util.function.LongToDoubleFunction after) { return s -> after.applyAsDouble(applyAsLong(s)); } public default Morphism andThen(java.util.function.LongFunction after) { return s -> after.apply(applyAsLong(s)); } public default IntToLongMorphism compose(java.util.function.IntFunction before) { return s -> applyAsLong(before.apply(s)); } public default LongMorphism compose(java.util.function.LongFunction before) { return s -> applyAsLong(before.apply(s)); } public default DoubleToLongMorphism compose(java.util.function.DoubleFunction before) { return s -> applyAsLong(before.apply(s)); } @Override public default ObjToLongMorphism compose(java.util.function.Function before) { return s -> applyAsLong(before.apply(s)); } } interface LongToIntMorphism extends LongToObjMorphism, ObjToIntMorphism, java.util.function.LongToIntFunction { @Override public default Integer apply(Long operand) { return applyAsInt((long) operand); } @Override public default Integer apply(long operand) { return applyAsInt(operand); } @Override public default int applyAsInt(Long operand) { return applyAsInt((long) operand); } @Override public default LongToIntMorphism andThen(java.util.function.IntUnaryOperator after) { return s -> after.applyAsInt(applyAsInt(s)); } @Override public default LongMorphism andThen(java.util.function.IntToLongFunction after) { return s -> after.applyAsLong(applyAsInt(s)); } @Override public default LongToDoubleMorphism andThen(java.util.function.IntToDoubleFunction after) { return s -> after.applyAsDouble(applyAsInt(s)); } @Override public default LongToObjMorphism andThen(java.util.function.IntFunction after) { return s -> after.apply(applyAsInt(s)); } @Override public default IntMorphism compose(java.util.function.IntToLongFunction before) { return s -> applyAsInt(before.applyAsLong(s)); } @Override public default LongToIntMorphism compose(java.util.function.LongUnaryOperator before) { return s -> applyAsInt(before.applyAsLong(s)); } @Override public default DoubleToIntMorphism compose(java.util.function.DoubleToLongFunction before) { return s -> applyAsInt(before.applyAsLong(s)); } @Override public default ObjToIntMorphism compose(java.util.function.ToLongFunction before) { return s -> applyAsInt(before.applyAsLong(s)); } } interface LongToDoubleMorphism extends LongToObjMorphism, ObjToDoubleMorphism, java.util.function.LongToDoubleFunction { @Override public default Double apply(Long operand) { return applyAsDouble((long) operand); } @Override public default Double apply(long operand) { return applyAsDouble(operand); } @Override public default double applyAsDouble(Long operand) { return applyAsDouble((long) operand); } @Override public default LongToIntMorphism andThen(java.util.function.DoubleToIntFunction after) { return s -> after.applyAsInt(applyAsDouble(s)); } @Override public default LongMorphism andThen(java.util.function.DoubleToLongFunction after) { return s -> after.applyAsLong(applyAsDouble(s)); } @Override public default LongToDoubleMorphism andThen(java.util.function.DoubleUnaryOperator after) { return s -> after.applyAsDouble(applyAsDouble(s)); } @Override public default LongToObjMorphism andThen(java.util.function.DoubleFunction after) { return s -> after.apply(applyAsDouble(s)); } @Override public default IntToDoubleMorphism compose(java.util.function.IntToLongFunction before) { return s -> applyAsDouble(before.applyAsLong(s)); } @Override public default LongToDoubleMorphism compose(java.util.function.LongUnaryOperator before) { return s -> applyAsDouble(before.applyAsLong(s)); } @Override public default DoubleMorphism compose(java.util.function.DoubleToLongFunction before) { return s -> applyAsDouble(before.applyAsLong(s)); } @Override public default ObjToDoubleMorphism compose(java.util.function.ToLongFunction before) { return s -> applyAsDouble(before.applyAsLong(s)); } } interface IntToLongMorphism extends IntToObjMorphism, ObjToLongMorphism, java.util.function.IntToLongFunction { @Override public default Long apply(Integer operand) { return applyAsLong((int) operand); } @Override public default Long apply(int operand) { return applyAsLong(operand); } @Override public default long applyAsLong(Integer operand) { return applyAsLong((int) operand); } @Override public default IntMorphism andThen(java.util.function.LongToIntFunction after) { return s -> after.applyAsInt(applyAsLong(s)); } @Override public default IntToLongMorphism andThen(java.util.function.LongUnaryOperator after) { return s -> after.applyAsLong(applyAsLong(s)); } @Override public default IntToDoubleMorphism andThen(java.util.function.LongToDoubleFunction after) { return s -> after.applyAsDouble(applyAsLong(s)); } @Override public default IntToObjMorphism andThen(java.util.function.LongFunction after) { return s -> after.apply(applyAsLong(s)); } @Override public default IntToLongMorphism compose(java.util.function.IntUnaryOperator before) { return s -> applyAsLong(before.applyAsInt(s)); } @Override public default LongMorphism compose(java.util.function.LongToIntFunction before) { return s -> applyAsLong(before.applyAsInt(s)); } @Override public default DoubleToLongMorphism compose(java.util.function.DoubleToIntFunction before) { return s -> applyAsLong(before.applyAsInt(s)); } @Override public default ObjToLongMorphism compose(java.util.function.ToIntFunction before) { return s -> applyAsLong(before.applyAsInt(s)); } } interface DoubleToLongMorphism extends DoubleToObjMorphism, ObjToLongMorphism, java.util.function.DoubleToLongFunction { @Override public default Long apply(Double operand) { return applyAsLong((double) operand); } @Override public default Long apply(double operand) { return applyAsLong(operand); } @Override public default long applyAsLong(Double operand) { return applyAsLong((double) operand); } @Override public default DoubleToIntMorphism andThen(java.util.function.LongToIntFunction after) { return s -> after.applyAsInt(applyAsLong(s)); } @Override public default DoubleToLongMorphism andThen(java.util.function.LongUnaryOperator after) { return s -> after.applyAsLong(applyAsLong(s)); } @Override public default DoubleMorphism andThen(java.util.function.LongToDoubleFunction after) { return s -> after.applyAsDouble(applyAsLong(s)); } @Override public default DoubleToObjMorphism andThen(java.util.function.LongFunction after) { return s -> after.apply(applyAsLong(s)); } @Override public default IntToLongMorphism compose(java.util.function.IntToDoubleFunction before) { return s -> applyAsLong(before.applyAsDouble(s)); } @Override public default LongMorphism compose(java.util.function.LongToDoubleFunction before) { return s -> applyAsLong(before.applyAsDouble(s)); } @Override public default DoubleToLongMorphism compose(java.util.function.DoubleUnaryOperator before) { return s -> applyAsLong(before.applyAsDouble(s)); } @Override public default ObjToLongMorphism compose(java.util.function.ToDoubleFunction before) { return s -> applyAsLong(before.applyAsDouble(s)); } } interface Magma extends java.util.function.BinaryOperator{ public default EndoMorphism partial(T bind) { return t -> apply(bind, t); } } interface IntToObjMorphism extends Morphism, java.util.function.IntFunction { @Override public default T apply(Integer operand) { return apply((int) operand); } public default IntMorphism andThen(java.util.function.ToIntFunction after) { return s -> after.applyAsInt(apply(s)); } public default IntToLongMorphism andThen(java.util.function.ToLongFunction after) { return s -> after.applyAsLong(apply(s)); } public default IntToDoubleMorphism andThen(java.util.function.ToDoubleFunction after) { return s -> after.applyAsDouble(apply(s)); } @Override public default IntToObjMorphism andThen(java.util.function.Function after) { return s -> after.apply(apply(s)); } public default IntToObjMorphism compose(java.util.function.IntUnaryOperator before) { return s -> apply(before.applyAsInt(s)); } public default LongToObjMorphism compose(java.util.function.LongToIntFunction before) { return s -> apply(before.applyAsInt(s)); } public default DoubleToObjMorphism compose(java.util.function.DoubleToIntFunction before) { return s -> apply(before.applyAsInt(s)); } public default Morphism compose(java.util.function.ToIntFunction before) { return s -> apply(before.applyAsInt(s)); } } interface DoubleToObjMorphism extends Morphism, java.util.function.DoubleFunction { @Override public default T apply(Double operand) { return apply((double) operand); } public default DoubleToIntMorphism andThen(java.util.function.ToIntFunction after) { return s -> after.applyAsInt(apply(s)); } public default DoubleToLongMorphism andThen(java.util.function.ToLongFunction after) { return s -> after.applyAsLong(apply(s)); } public default DoubleMorphism andThen(java.util.function.ToDoubleFunction after) { return s -> after.applyAsDouble(apply(s)); } @Override public default DoubleToObjMorphism andThen(java.util.function.Function after) { return s -> after.apply(apply(s)); } public default IntToObjMorphism compose(java.util.function.IntToDoubleFunction before) { return s -> apply(before.applyAsDouble(s)); } public default LongToObjMorphism compose(java.util.function.LongToDoubleFunction before) { return s -> apply(before.applyAsDouble(s)); } public default DoubleToObjMorphism compose(java.util.function.DoubleUnaryOperator before) { return s -> apply(before.applyAsDouble(s)); } public default Morphism compose(java.util.function.ToDoubleFunction before) { return s -> apply(before.applyAsDouble(s)); } } interface ObjToIntMorphism extends Morphism, java.util.function.ToIntFunction { @Override public default Integer apply(S operand) { return applyAsInt(operand); } public default ObjToIntMorphism andThen(java.util.function.IntUnaryOperator after) { return s -> after.applyAsInt(applyAsInt(s)); } public default ObjToLongMorphism andThen(java.util.function.IntToLongFunction after) { return s -> after.applyAsLong(applyAsInt(s)); } public default ObjToDoubleMorphism andThen(java.util.function.IntToDoubleFunction after) { return s -> after.applyAsDouble(applyAsInt(s)); } public default Morphism andThen(java.util.function.IntFunction after) { return s -> after.apply(applyAsInt(s)); } public default IntMorphism compose(java.util.function.IntFunction before) { return s -> applyAsInt(before.apply(s)); } public default LongToIntMorphism compose(java.util.function.LongFunction before) { return s -> applyAsInt(before.apply(s)); } public default DoubleToIntMorphism compose(java.util.function.DoubleFunction before) { return s -> applyAsInt(before.apply(s)); } @Override public default ObjToIntMorphism compose(java.util.function.Function before) { return s -> applyAsInt(before.apply(s)); } } interface ObjToDoubleMorphism extends Morphism, java.util.function.ToDoubleFunction { @Override public default Double apply(S operand) { return applyAsDouble(operand); } public default ObjToIntMorphism andThen(java.util.function.DoubleToIntFunction after) { return s -> after.applyAsInt(applyAsDouble(s)); } public default ObjToLongMorphism andThen(java.util.function.DoubleToLongFunction after) { return s -> after.applyAsLong(applyAsDouble(s)); } public default ObjToDoubleMorphism andThen(java.util.function.DoubleUnaryOperator after) { return s -> after.applyAsDouble(applyAsDouble(s)); } public default Morphism andThen(java.util.function.DoubleFunction after) { return s -> after.apply(applyAsDouble(s)); } public default IntToDoubleMorphism compose(java.util.function.IntFunction before) { return s -> applyAsDouble(before.apply(s)); } public default LongToDoubleMorphism compose(java.util.function.LongFunction before) { return s -> applyAsDouble(before.apply(s)); } public default DoubleMorphism compose(java.util.function.DoubleFunction before) { return s -> applyAsDouble(before.apply(s)); } @Override public default ObjToDoubleMorphism compose(java.util.function.Function before) { return s -> applyAsDouble(before.apply(s)); } } interface IntMorphism extends IntToObjMorphism, ObjToIntMorphism, java.util.function.IntUnaryOperator { @Override public default Integer apply(Integer operand) { return applyAsInt((int) operand); } @Override public default Integer apply(int operand) { return applyAsInt(operand); } @Override public default int applyAsInt(Integer operand) { return applyAsInt((int) operand); } @Override public default IntMorphism andThen(java.util.function.IntUnaryOperator after) { return s -> after.applyAsInt(applyAsInt(s)); } @Override public default IntToLongMorphism andThen(java.util.function.IntToLongFunction after) { return s -> after.applyAsLong(applyAsInt(s)); } @Override public default IntToDoubleMorphism andThen(java.util.function.IntToDoubleFunction after) { return s -> after.applyAsDouble(applyAsInt(s)); } public default IntMorphism andThen(IntMorphism after) { return s -> after.applyAsInt(applyAsInt(s)); } @Override public default IntToObjMorphism andThen(java.util.function.IntFunction after) { return s -> after.apply(applyAsInt(s)); } @Override public default IntMorphism compose(java.util.function.IntUnaryOperator before) { return s -> applyAsInt(before.applyAsInt(s)); } @Override public default LongToIntMorphism compose(java.util.function.LongToIntFunction before) { return s -> applyAsInt(before.applyAsInt(s)); } @Override public default DoubleToIntMorphism compose(java.util.function.DoubleToIntFunction before) { return s -> applyAsInt(before.applyAsInt(s)); } public default IntMorphism compose(IntMorphism before) { return s -> applyAsInt(before.applyAsInt(s)); } @Override public default ObjToIntMorphism compose(java.util.function.ToIntFunction before) { return s -> applyAsInt(before.applyAsInt(s)); } public static Associative composition() { return (t, u) -> t.andThen(u); } } interface DoubleToIntMorphism extends DoubleToObjMorphism, ObjToIntMorphism, java.util.function.DoubleToIntFunction { @Override public default Integer apply(Double operand) { return applyAsInt((double) operand); } @Override public default Integer apply(double operand) { return applyAsInt(operand); } @Override public default int applyAsInt(Double operand) { return applyAsInt((double) operand); } @Override public default DoubleToIntMorphism andThen(java.util.function.IntUnaryOperator after) { return s -> after.applyAsInt(applyAsInt(s)); } @Override public default DoubleToLongMorphism andThen(java.util.function.IntToLongFunction after) { return s -> after.applyAsLong(applyAsInt(s)); } @Override public default DoubleMorphism andThen(java.util.function.IntToDoubleFunction after) { return s -> after.applyAsDouble(applyAsInt(s)); } @Override public default DoubleToObjMorphism andThen(java.util.function.IntFunction after) { return s -> after.apply(applyAsInt(s)); } @Override public default IntMorphism compose(java.util.function.IntToDoubleFunction before) { return s -> applyAsInt(before.applyAsDouble(s)); } @Override public default LongToIntMorphism compose(java.util.function.LongToDoubleFunction before) { return s -> applyAsInt(before.applyAsDouble(s)); } @Override public default DoubleToIntMorphism compose(java.util.function.DoubleUnaryOperator before) { return s -> applyAsInt(before.applyAsDouble(s)); } @Override public default ObjToIntMorphism compose(java.util.function.ToDoubleFunction before) { return s -> applyAsInt(before.applyAsDouble(s)); } } interface IntToDoubleMorphism extends IntToObjMorphism, ObjToDoubleMorphism, java.util.function.IntToDoubleFunction { @Override public default Double apply(Integer operand) { return applyAsDouble((int) operand); } @Override public default Double apply(int operand) { return applyAsDouble(operand); } @Override public default double applyAsDouble(Integer operand) { return applyAsDouble((int) operand); } @Override public default IntMorphism andThen(java.util.function.DoubleToIntFunction after) { return s -> after.applyAsInt(applyAsDouble(s)); } @Override public default IntToLongMorphism andThen(java.util.function.DoubleToLongFunction after) { return s -> after.applyAsLong(applyAsDouble(s)); } @Override public default IntToDoubleMorphism andThen(java.util.function.DoubleUnaryOperator after) { return s -> after.applyAsDouble(applyAsDouble(s)); } @Override public default IntToObjMorphism andThen(java.util.function.DoubleFunction after) { return s -> after.apply(applyAsDouble(s)); } @Override public default IntToDoubleMorphism compose(java.util.function.IntUnaryOperator before) { return s -> applyAsDouble(before.applyAsInt(s)); } @Override public default LongToDoubleMorphism compose(java.util.function.LongToIntFunction before) { return s -> applyAsDouble(before.applyAsInt(s)); } @Override public default DoubleMorphism compose(java.util.function.DoubleToIntFunction before) { return s -> applyAsDouble(before.applyAsInt(s)); } @Override public default ObjToDoubleMorphism compose(java.util.function.ToIntFunction before) { return s -> applyAsDouble(before.applyAsInt(s)); } } interface DoubleMorphism extends DoubleToObjMorphism, ObjToDoubleMorphism, java.util.function.DoubleUnaryOperator { @Override public default Double apply(Double operand) { return applyAsDouble((double) operand); } @Override public default Double apply(double operand) { return applyAsDouble(operand); } @Override public default double applyAsDouble(Double operand) { return applyAsDouble((double) operand); } @Override public default DoubleToIntMorphism andThen(java.util.function.DoubleToIntFunction after) { return s -> after.applyAsInt(applyAsDouble(s)); } @Override public default DoubleToLongMorphism andThen(java.util.function.DoubleToLongFunction after) { return s -> after.applyAsLong(applyAsDouble(s)); } @Override public default DoubleMorphism andThen(java.util.function.DoubleUnaryOperator after) { return s -> after.applyAsDouble(applyAsDouble(s)); } public default DoubleMorphism andThen(DoubleMorphism after) { return s -> after.applyAsDouble(applyAsDouble(s)); } public default DoubleToObjMorphism andThen(DoubleToObjMorphism after) { return s -> after.apply(applyAsDouble(s)); } @Override public default IntToDoubleMorphism compose(java.util.function.IntToDoubleFunction before) { return s -> applyAsDouble(before.applyAsDouble(s)); } @Override public default LongToDoubleMorphism compose(java.util.function.LongToDoubleFunction before) { return s -> applyAsDouble(before.applyAsDouble(s)); } @Override public default DoubleMorphism compose(java.util.function.DoubleUnaryOperator before) { return s -> applyAsDouble(before.applyAsDouble(s)); } public default DoubleMorphism compose(DoubleMorphism before) { return s -> applyAsDouble(before.applyAsDouble(s)); } public default ObjToDoubleMorphism compose(ObjToDoubleMorphism before) { return s -> applyAsDouble(before.applyAsDouble(s)); } public static Associative composition() { return (t, u) -> t.andThen(u); } }