Your problem sounds to me like this:
given binary tree
=> flatten the right most branch
=> reverse the flatten list
=> make it a binary tree
t(a,t(b, t(c)) =>
=> [a, b, c]
=> [c, b, a]
=> t(c, t(b, t(a))
Am I missing something ? Anyway, I hope this help.
> On Jun 3, 2017, at 17:45, Juan <juaan...@gmail.com
> Hi !
> I want to know how to reverse the nodes in a binary tree like this :
> I can only use this ABN representation as lists and the following constructors and selectors of
> the abstract data type.
> root([_,N,_], N).
> hi([HI,_,_],HI). %left son
> hd([_,_,HD],HD). %right son
> I want to know how could I make a swap predicate like this
> that working like this:
> ?- swap(A4,B).
> Any clues ?
> You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com
> Visit this group at https://groups.google.com/group/swi-prolog
> For more options, visit https://groups.google.com/d/optout