I thought I'd put that in treehugger, but turned out I only
implemented in scalaxb:
def INFIX_CHAIN(op: String, seq: Iterable[Tree]): Tree =
seq.toList match {
case Nil => EmptyTree
case List(x) => x
case xs => xs reduceLeft { (x, y) => x INFIX(op) APPLY y }
}
scala> val list = List(REF("a"), REF("b"), REF("c"), REF("d"))
list: List[treehugger.package.forest.Ident] = List(Ident(a), Ident(b),
Ident(c), Ident(d))
scala> INFIX_CHAIN("|•|", list)
res7: treehugger.package.forest.Tree =
Infix(Infix(Infix(Ident(a),|•|,List(Ident(b))),|•|,List(Ident(c))),|•|,List(Ident(d)))
scala> treeToString(res7)
res8: String = a |•| b |•| c |•| d
-eugene
> --
> You received this message because you are subscribed to the Google Groups "treehugger-scala" group.
> To view this discussion on the web visit
https://groups.google.com/d/msg/treehugger-scala/-/zXwfzZSKfvAJ.
> To post to this group, send email to
treehugg...@googlegroups.com.
> To unsubscribe from this group, send email to
treehugger-sca...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/treehugger-scala?hl=en.
>