Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cons getting, setting and unification #7

Open
matko opened this issue Oct 4, 2021 · 1 comment
Open

Cons getting, setting and unification #7

matko opened this issue Oct 4, 2021 · 1 comment

Comments

@matko
Copy link
Collaborator

matko commented Oct 4, 2021

While there is code for getting, setting and unifying lists with prolog terms, there's nothing for the more primitive cons cells that underly these lists. This is annoying, because not every data structure that can be built with cons cells is necessarily going to be a list. Furthermore, certain approaches to list building are easier when we can leave the tail as a variable which is then unified later.

We therefore need a way to work with cons cells directly. This'll also help in implementing the cons part of #5.

See #4 for earlier discussion on this.

@ThePuzzlemaker
Copy link
Contributor

You can implement this similarly to unifying with a list, just instead of unifying the end with a nil element, you can unify it with a user-specified tail. That way you're only using the "linked" part of the linked list for the part that's necessary thus not sacrificing performance by requiring use of some linked list structure.

In fact, regular lists are a special case of this list of terms + a tail unification, where the tail is nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants