Skip to content

Understanding Scryer's stack frame management #2654

Answered by triska
dnmfarrell asked this question in Q&A
Discussion options

You must be logged in to vote

Personally, I aim for correctness and elegance. We can use Prolog itself to query the defined relations in various ways, and test them very exhaustively.

In this concrete example, let's ask Prolog what the predicate means. Let's start with the most general query: Which solutions are there in general?

?- height(D, H).
   D = nil, H = -1.

From this, it appears that the entire relation can be defined with a single fact. On the other hand, this is probably not the intended relation, so there is likely a mistake in the code.

Regarding efficiency: For large data structures, the used algorithms must generally stay sub-quadratic, and otherwise quickly become infeasible.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@dnmfarrell
Comment options

@triska
Comment options

Answer selected by dnmfarrell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants