Re: Ann: delay pack

Alan Baljeu <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
How does delay know when the argument is ready to be called?
 
Alan Baljeu


----- Original Message -----
From: Michael Hendricks <[email protected]>
To: Prolog mailing list <[email protected]>
Cc: 
Sent: Friday, August 9, 2013 1:25:28 PM
Subject: [SWIPL] Ann: delay pack

I've just released a pack which helps avoid instantiation errors with
built-in predicates.  By using delay/1 a single clause can operate in many
modes without manually re-ordering goals.  You can read the full
documentation <http://www.swi-prolog.org/pack/list?p=delay> for details.
Here's a quick demo:

?- delay(succ(A,B)), A=1.
A = 1,
B = 2.

?- delay(plus(A,3,C)), C=5.
A = 2,
C = 5.

?- delay(univ(T,Name,Args)), Name=hello, Args=[world].
T = hello(world),
Name = hello,
Args = [world].

I finally got tired enough of writing the same when/2 goals over and over
that I figured it was time for a library.  I find this style especially
helpful with DCGs where it allows predicates to both generate and parse
content with a single definition.

As always, feedback, criticism and pull requests are welcome.

-- 
Michael
-------------- next part --------------
HTML attachment scrubbed and removed
_______________________________________________
SWI-Prolog mailing list
[email protected]
https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.