From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: stefan Newsgroups: gmane.lisp.guile.devel Subject: prolog, pure guile scheme Date: Tue, 6 Jul 2010 23:52:47 +0200 Message-ID: <201007062352.47878.stefan.tampe@spray.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1278455502 7264 80.91.229.12 (6 Jul 2010 22:31:42 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 6 Jul 2010 22:31:42 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jul 07 00:31:41 2010 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OWGfx-0001ug-0u for guile-devel@m.gmane.org; Wed, 07 Jul 2010 00:31:37 +0200 Original-Received: from localhost ([127.0.0.1]:45728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWGfw-0001ut-DI for guile-devel@m.gmane.org; Tue, 06 Jul 2010 18:31:36 -0400 Original-Received: from [140.186.70.92] (port=51660 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OWGfr-0001tY-KH for guile-devel@gnu.org; Tue, 06 Jul 2010 18:31:32 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OWGfq-0008Uq-6g for guile-devel@gnu.org; Tue, 06 Jul 2010 18:31:31 -0400 Original-Received: from spsmtp02oc.mail2world.com ([74.202.142.198]:1708) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OWGfq-0008Uc-2e for guile-devel@gnu.org; Tue, 06 Jul 2010 18:31:30 -0400 Original-Received: from mail pickup service by spsmtp02oc.mail2world.com with Microsoft SMTPSVC; Tue, 6 Jul 2010 15:31:28 -0700 auth-sender: stefan.tampe@spray.se Original-Received: from 82.182.254.46 unverified ([82.182.254.46]) by spsmtp02oc.mail2world.com with Mail2World SMTP Server; Tue, 06 Jul 2010 15:31:27 -0700 User-Agent: KMail/1.12.4 (Linux/2.6.31.12-0.2-desktop; KDE/4.3.5; x86_64; ; ) X-Spam: [FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF,0,41]"\Miscellaneous\Strong" <0> X-OriginalArrivalTime: 06 Jul 2010 22:31:28.0165 (UTC) FILETIME=[F9938D50:01CB1D5A] X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10624 Archived-At: Hi, I made a pure guile scheme directory under language/prolog at git@gitorious.org:guile-unify/guile-unify.git, unify-iso branch! load the prolog-parser.scm in that directory and then use for example (prolog-it ) e.g. (prolog-it " queens(N,Qs) :- g_pk(N), rangeList(1,N,Ns),g_pk(Ns),queens3(Ns,[],Qs). queens3(UnplacedQs, SafeQs, Qs) :- selectq(Q, UnplacedQs, UnplacedQs1), \\+ attack(Q,SafeQs), queens3(UnplacedQs1,[Q|SafeQs],Qs). queens3([],Qs,Qs). attack(X,Xs) :- attack3(X, 1, Xs). attack3(X,N,[Y|_]) :- X =:= Y+N ; X =:= Y-N. attack3(X,N,[_|Ys]) :- N1 is N+1, attack3(X,N1,Ys). rangeList(M,N,[M]) :- M >= N, !. rangeList(M,N,[M|Tail]) :- M1 is M+1, rangeList(M1,N,Tail). selectq(X,[X|Xs],Xs). selectq(X,[Y|Ys],[Y|Zs]) :- selectq(X,Ys,Zs). ") you could run a query like (run "queens(10,X)" #f) Now this works but is slow as molasses. Not enteirly intentional. Part of the slowness is due to the match algorithm mimicking the fast one in the master repo. Now the main reason is due to a problem with prompts that I did not solve. So here is what I would like to use (match #:tag pr Z ((a X) (begin (do-something X pr) (abort-to-prompt pr))) ((b X) (b-it X))) And this translate to something like (call-with-prompt *prompt* (lambda () (let ((pr *prompt*)) (ma-it Z (a X) (begin (do-something X pr) ...) (abort-to-prompt pr)))) (lambda (s) ...)) Now this works if we stay in the function, but if do-something contains again a match constructed from the *prompt* prompt, then it get confused so I was thinking like *prompt* beeing like a fluid let but it's not as it seams. At the repo unify-iso I instead construct a fresh new prompt at each match invocation which of cause is very costly but correct. I suspect that there is a quick hack to fix this and therefore I ask if anyone can help? Interestingly in the master repo I hacked a prompt like feature that is not a delimited continuation but just keeps information of state to do a jump later on. Regards Stefan