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

Temporary fix for bug #7

Open
FemtoEmacs opened this issue Dec 22, 2019 · 0 comments
Open

Temporary fix for bug #7

FemtoEmacs opened this issue Dec 22, 2019 · 0 comments

Comments

@FemtoEmacs
Copy link
Collaborator

I placed a temporary fix for the neck-cut bug. I will not make a Pull request because I myself am not satisfied with the solution. It works, but is not very elegant. In any case, after the patch, I was able to solve Werner Hett's Ninety-Nine Prolog problems from 1 to 35. I used the numeration that appears at the page of UNICAMP, not Hett's. It seems that my awkward and coarse patch did not impaired the speed of wamcompiler. You will find wamcompiler with the patch and the Ninety-Nine Prolog problems here at the Femto Emacs fork of your repository:

https://github.com/FemtoEmacs/wamcompiler

You need to download three files for testing the Ninety-Nine Prolog problems, to wit:

  1. rnd.lisp -- this file contains a random number generator and need to be load before executing (repl)
  2. p99.pl -- that contains 35 problems from Hett's collection
  3. wamcompiler with the patch

In a nutshell, the patch introduces a `true` predicate in front of the cut, in case of neck-cut. Thus, the neck-cut becomes a normal cut.

```lisp
(defun add-true(s)
  (if (and (consp s) (equal (car s) '(|!|)) ) (cons '(|true|) s) s))

(defun divide-head-body (clause)
  (destructuring-bind
	(head body clause-type)
        (cond
            ( (and (eq (car clause) '|:-|) (= (arity clause) 2))
               (list (cadr clause) 
                     (add-true (flatten-comma (caddr clause))) 'rule))
;;; ... etc

(define-prolog-builtin "true" ()
  (let  ((wam-code '((proceed))))
    (setf *P* wam-code)))

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

1 participant