<< Demo022 >> << Section 13.7: Inspecting Compound Terms >> type Person = term; Alice, Mary, Kate, John => Person; woman (Person) => Person; man (Person) => Person; loves (Person, Person) => term; functor( woman(Mary))? arity( woman(Mary))? arity( Mary)? argument( woman(Mary),1)? Relation = loves( man( John), woman( Kate) ); Relation? argument( Relation, 2 )? set_argument ( Relation, 2, woman(Alice)); Relation? Leaves(Tree = term) -> multi( term); Leaves(Tree) = if arity (Tree) == 0 then Tree << is Leaf >> else Leaves (argument (Tree, 1..arity(Tree) ) ); Leaves (Relation)?