@Test public void serialize() throws IOException { final TRS<String> trs = TRS.parse( "add(0,$x) -> $x", "add(S($x),$y) -> S(add($x,$y))", "mul(0,$x) -> 0", "mul(S($x),$y) -> add(mul($x,$y),$y)" ); final byte[] data = IO.object.toByteArray(trs); Assert.assertEquals(IO.object.fromByteArray(data), trs); }
public static <V> TRS<V> parse( final Function<? super String, ? extends V> mapper, final String... rules ) { return new TRS<>( ISeq.of(rules) .map(rule -> TreeRewriteRule.parse(rule, mapper)) ); }
TRS implements TreeRewriter<V>, Serializable { public static <V> TRS<V> parse( final Function<? super String, ? extends V> mapper, final String... rules ) { return new TRS<>( ISeq.of(rules) .map(rule -> TreeRewriteRule.parse(rule, mapper)) ); } }
TRS implements TreeRewriter<V>, Serializable { public static <V> TRS<V> parse( final Function<? super String, ? extends V> mapper, final String... rules ) { return new TRS<>( ISeq.of(rules) .map(rule -> TreeRewriteRule.parse(rule, mapper)) ); } TRS(final ISeq<TreeRewriteRule<V>> rules); }
TRS implements TreeRewriter<V>, Serializable { public static <V> TRS<V> parse( final Function<? super String, ? extends V> mapper, final String... rules ) { return new TRS<>( ISeq.of(rules) .map(rule -> TreeRewriteRule.parse(rule, mapper)) ); } TRS(final ISeq<TreeRewriteRule<V>> rules); @Override int rewrite(final TreeNode<V> tree, final int limit); TRS<B> map(final Function<? super V, ? extends B> mapper); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); static TRS<V> parse(
		final Function<? super String, ? extends V> mapper,
		final String... rules
	); static TRS<String> parse(final String... rules); }
TRS implements TreeRewriter<V>, Serializable { public static <V> TRS<V> parse( final Function<? super String, ? extends V> mapper, final String... rules ) { return new TRS<>( ISeq.of(rules) .map(rule -> TreeRewriteRule.parse(rule, mapper)) ); } TRS(final ISeq<TreeRewriteRule<V>> rules); @Override int rewrite(final TreeNode<V> tree, final int limit); TRS<B> map(final Function<? super V, ? extends B> mapper); @Override int hashCode(); @Override boolean equals(final Object obj); @Override String toString(); static TRS<V> parse(
		final Function<? super String, ? extends V> mapper,
		final String... rules
	); static TRS<String> parse(final String... rules);  }