Skip to content

Instantly share code, notes, and snippets.

View nicoabie's full-sized avatar
💭
keep fighting!

Nico Gallinal nicoabie

💭
keep fighting!
View GitHub Profile
@nicoabie
nicoabie / pptree.pl
Created March 4, 2019 19:53
Pretty print a syntactic tree using prolog.
pptree(Term) :-
functor(Term, Name, Arity),
write(Name),
write('('),
pptree_children(Term, 1, Arity, 1).
% prints atomic siblings without last
pptree_children(Term, ChildN, Total, Level) :-
ChildN < Total,
arg(ChildN, Term, Child),