Not logged in. · Lost password · Register

riwo
Member for 2 months
7 posts
Subject: Empty tree in problem 3.2
Unfortunately I don't quite understand how the empty tree with no nodes should be represented in the definition of trees in problem 3.2, for reference:

subtrees([]).
istree(tree(Value,Children)) :− string(Value),subtrees(Children).
subtrees([(Cost,T)|Rest]) :− number(Cost),istree(T), subtrees(Rest).

Can anyone help?
katjab
Member for 2 months
54 posts
You can make a tree with just the root node "A" and no children like this:
tree("A",[])
I hope this helps.

You can check out more examples in the notebook:
https://swish.swi-prolog.org/example/lists.pl
Since Swish is being particularly unreliable this year, I'll also post the code from the notebook to
https://kwarc.info/teaching/AI/resources/
This post was edited on 2019-11-11, 11:14 by katjab.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Datenschutz | Kontakt
Powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2011 by Yves Goergen