<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Alp Mestan's Corner &#187; Prolog</title>
	<atom:link href="http://blog.mestan.fr/category/programming/prolog/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.mestan.fr</link>
	<description>My programming, AI and Maths stuffs</description>
	<pubDate>Thu, 24 Sep 2009 21:10:42 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Using OCaml&#8217;s module functors to provide monadic contexts for Batteries</title>
		<link>http://blog.mestan.fr/2009/04/24/using-ocamls-module-functors-to-provide-monadic-contexts-for-batteries/</link>
		<comments>http://blog.mestan.fr/2009/04/24/using-ocamls-module-functors-to-provide-monadic-contexts-for-batteries/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 17:29:35 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
		
		<category><![CDATA[Haskell]]></category>

		<category><![CDATA[OCaml]]></category>

		<category><![CDATA[Programming]]></category>

		<category><![CDATA[Prolog]]></category>

		<category><![CDATA[Scientific Computing]]></category>

		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[batteries]]></category>

		<category><![CDATA[enum]]></category>

		<category><![CDATA[functor]]></category>

		<category><![CDATA[included]]></category>

		<category><![CDATA[module]]></category>

		<category><![CDATA[monads]]></category>

		<guid isPermaLink="false">http://blog.mestan.fr/?p=30</guid>
		<description><![CDATA[Hi,
Several days ago, bluestorm and I started working on monads-related stuffs for Batteries, so that we&#8217;d be able to provide a good API for writing and using monads in Objective Caml.
Well, we&#8217;ve now written the basis of the future monad-related functions and modules in Batteries.
Of course, we&#8217;ve introduced two key monads, keeping Batteries&#8217; spirit : [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Several days ago, bluestorm and I <a href="http://lists.forge.ocamlcore.org/pipermail/batteries-devel/2009-April/000703.html">started working on monads-related stuffs for Batteries</a>, so that we&#8217;d be able to provide a good API for writing and using monads in Objective Caml.</p>
<p>Well, we&#8217;ve now written the basis of the future monad-related functions and modules in Batteries.</p>
<p>Of course, we&#8217;ve introduced two key monads, keeping Batteries&#8217; spirit : the Option monad and the Enum monad. The first is the equivalent of Haskell&#8217;s Maybe monad, whereas the latter is somehow &#8220;equivalent&#8221; to Haskell&#8217;s List monad, with the difference that Batteries&#8217; key data structure is Enum, whereas Haskell&#8217;s standard library&#8217;s is List.</p>
<p>We&#8217;ve also written two key functions for working with monads&#8230; If you are familiar with foldM and sequence in Haskell, working over lists, you won&#8217;t be lost when using our fold_monad and sequence functions, working over enums.</p>
<p>Hey, wait a minute&#8230;<br />
<span id="more-30"></span></p>
<p>OCaml&#8217;s hasn&#8217;t typeclasses ! How can we &#8220;overload&#8221; bind and return and make sequence and fold_monac guess what is the monad they have to work in ?<br />
The answer is <a href="http://alain.frisch.fr/soft#openin">the pa_openin syntax extension</a>.</p>
<p>Now, even if we&#8217;re working on adding some trivial uses of our monad related stuffs in Batteries&#8217; testsuite, you can take a look at the following sample which works on my local Batteries version&#8230;</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p30code2'); return false;">View Code</a> OCAML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p302"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p30code2"><pre class="ocaml" style="font-family:monospace;"><span style="color: #a52a2a;">#</span> <span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">module</span> M <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">Option</span><span style="color: #a52a2a;">.</span><span style="color: #060;">Monad</span> <span style="color: #06c; font-weight: bold;">in</span> <span style="color: #06c; font-weight: bold;">open</span> Enum<span style="color: #a52a2a;">.</span><span style="color: #060;">WithMonad</span><span style="color: #6c6;">&#40;</span>M<span style="color: #6c6;">&#41;</span>,M <span style="color: #06c; font-weight: bold;">in</span>
       sequence <span style="color: #6c6;">&#91;</span>? Some x <span style="color: #a52a2a;">|</span>x <span style="color: #a52a2a;">&lt;-</span> <span style="color: #c6c;">1</span><span style="color: #a52a2a;">--</span><span style="color: #c6c;">100</span> <span style="color: #6c6;">&#93;</span> <span style="color: #a52a2a;">;;</span>
<span style="color: #a52a2a;">-</span> <span style="color: #a52a2a;">:</span> int Batteries<span style="color: #a52a2a;">.</span><span style="color: #060;">Enum</span><span style="color: #a52a2a;">.</span><span style="color: #060;">t</span> <span style="color: #06c; font-weight: bold;">option</span> <span style="color: #a52a2a;">=</span> Some <span style="color: #a52a2a;">&lt;</span>abstr<span style="color: #a52a2a;">&gt;</span>
<span style="color: #a52a2a;">#</span> <span style="color: #06c; font-weight: bold;">let</span> <span style="color: #06c; font-weight: bold;">module</span> M <span style="color: #a52a2a;">=</span> <span style="color: #06c; font-weight: bold;">Option</span><span style="color: #a52a2a;">.</span><span style="color: #060;">Monad</span> <span style="color: #06c; font-weight: bold;">in</span> <span style="color: #06c; font-weight: bold;">open</span> Enum<span style="color: #a52a2a;">.</span><span style="color: #060;">WithMonad</span><span style="color: #6c6;">&#40;</span>M<span style="color: #6c6;">&#41;</span>,M <span style="color: #06c; font-weight: bold;">in</span>
       sequence <span style="color: #6c6;">&#40;</span><span style="color: #06c; font-weight: bold;">List</span><span style="color: #a52a2a;">.</span><span style="color: #060;">enum</span> <span style="color: #6c6;">&#91;</span>Some <span style="color: #c6c;">1</span><span style="color: #a52a2a;">;</span> None <span style="color: #a52a2a;">;</span> Some <span style="color: #c6c;">3</span><span style="color: #6c6;">&#93;</span><span style="color: #6c6;">&#41;</span> <span style="color: #a52a2a;">;;</span>
<span style="color: #a52a2a;">-</span> <span style="color: #a52a2a;">:</span> int Batteries<span style="color: #a52a2a;">.</span><span style="color: #060;">Enum</span><span style="color: #a52a2a;">.</span><span style="color: #060;">t</span> <span style="color: #06c; font-weight: bold;">option</span> <span style="color: #a52a2a;">=</span> None</pre></td></tr></table></div>

<p>By the way, do you think, you, user, the (>>=) operator should be provided by default in our XXX.Monad modules ? </p>
<p>Enjoy !</p>
<p>[Link : <a href="http://git.ocamlcore.org/cgi-bin/gitweb.cgi?p=batteries/batteries.git;a=commit;h=e4564299fb4daef2dffd1bf6787b360dc5f61a6e">my git commit</a>]</p>

]]></content:encoded>
			<wfw:commentRss>http://blog.mestan.fr/2009/04/24/using-ocamls-module-functors-to-provide-monadic-contexts-for-batteries/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Network programming with Prolog (SWI)</title>
		<link>http://blog.mestan.fr/2008/06/26/network-programming-with-prolog-swi/</link>
		<comments>http://blog.mestan.fr/2008/06/26/network-programming-with-prolog-swi/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 20:10:13 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
		
		<category><![CDATA[Prolog]]></category>

		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://blog.mestan.fr/?p=10</guid>
		<description><![CDATA[Network programming is an important part of the development process. Nowadays, a good programming language must ease network programming.
The Prolog programming language includes this feature. In fact, as I&#8217;m working with SWI-Prolog, I know this feature is (well) covered by this Prolog distribution but I suppose that other distributions also give tools for network programming [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Network programming</strong> is an important part of the development process. Nowadays, a good programming language <strong>must</strong> ease network programming.</p>
<p>The <strong>Prolog programming language</strong> includes this feature. In fact, as I&#8217;m working with <strong>SWI-Prolog</strong>, I know this feature is (well) covered by this Prolog distribution but I suppose that other distributions also give tools for network programming in Prolog.</p>
<p><img src='http://www.jefaismescartons.fr/images/stories/imgsite/network.gif' alt='Network' class='aligncenter' /></p>
<p><span id="more-10"></span></p>
<p>SWI-Prolog&#8217;s network programming module is a binding of the C POSIX API so its use is quite similar.</p>
<p>Here is some predicates of the socket library.</p>
<ul>
<li><em>tcp_socket(-SocketId)</em></li>
<li><em>tcp_close_socket(+SocketId)</em></li>
<li><em>tcp_open_socket(+SocketId, -InStream, -OutStream)</em></li>
<li><em>tcp_bind(+Socket, ?Port)</em></li>
<li><em>tcp_listen(+Socket, +Backlog)</em></li>
<li><em>tcp_accept(+Socket, -Slave, -Peer)</em></li>
<li><em>tcp_connect(+Socket, +Host:+Port)</em></li>
<li><em>udp_socket(-Socket)</em></li>
<li><em>udp_receive(+Socket, -Data, -From, +Options)</em></li>
<li><em>udp_send(+Socket, +Data, +To, +Options)</em></li>
</ul>
<p>For tcp sockets, you can simply use the write* and read* predicates.</p>
<p>To use those functions, sometimes you&#8217;ll have to put :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p10code7'); return false;">View Code</a> PROLOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p107"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p10code7"><pre class="prolog" style="font-family:monospace;"><span style="color: #339933;">:-</span> use<span style="color: #008080;">_module</span><span style="color: #009900;">&#40;</span>library<span style="color: #009900;">&#40;</span>socket<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></td></tr></table></div>

<p>at the beggining of your Prolog source file.</p>
<p>Here is a sample Prolog program that creates a server. When a client gets connected to the server, it sends it <em>Welcome on myPrologServer</em> and then closes the connection.<br />
<</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p10code8'); return false;">View Code</a> PROLOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p108"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p10code8"><pre class="prolog" style="font-family:monospace;"><span style="color: #339933;">:-</span> use<span style="color: #008080;">_module</span><span style="color: #009900;">&#40;</span>library<span style="color: #009900;">&#40;</span>socket<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
init <span style="color: #339933;">:-</span>
	create<span style="color: #008080;">_server</span><span style="color: #009900;">&#40;</span><span style="color: #800080;">2302</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Welcome on myPrologServer\n'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
create<span style="color: #008080;">_server</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Port</span><span style="color: #339933;">,</span><span style="color: #008080;">Txt</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:-</span>
	tcp<span style="color: #008080;">_socket</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Socket</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	tcp<span style="color: #008080;">_bind</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Socket</span><span style="color: #339933;">,</span><span style="color: #008080;">Port</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	tcp<span style="color: #008080;">_listen</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Socket</span><span style="color: #339933;">,</span><span style="color: #800080;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	tcp<span style="color: #008080;">_open_socket</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Socket</span><span style="color: #339933;">,</span><span style="color: #008080;">AcceptFd</span><span style="color: #339933;">,</span><span style="color: #008080;">_</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	server<span style="color: #008080;">_loop</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">AcceptFd</span><span style="color: #339933;">,</span><span style="color: #008080;">Txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
server<span style="color: #008080;">_loop</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">AcceptFd</span><span style="color: #339933;">,</span><span style="color: #008080;">Txt</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:-</span>
	tcp<span style="color: #008080;">_accept</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">AcceptFd</span><span style="color: #339933;">,</span><span style="color: #008080;">Socket2</span><span style="color: #339933;">,</span><span style="color: #008080;">_</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	tcp<span style="color: #008080;">_open_socket</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Socket2</span><span style="color: #339933;">,</span><span style="color: #008080;">In</span><span style="color: #339933;">,</span><span style="color: #008080;">Out</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">write</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Out</span><span style="color: #339933;">,</span><span style="color: #008080;">Txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">In</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #990000;">close</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">Out</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	server<span style="color: #008080;">_loop</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">AcceptFd</span><span style="color: #339933;">,</span><span style="color: #008080;">Txt</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></td></tr></table></div>

<p>The code is quite short and is very easy to understand.</p>
<p>Now, launch <em>swipl</em>, consult your file (<em>test_socket.pl</em> for me) and launch the <strong>init</strong> predicate.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p10code9'); return false;">View Code</a> CONSOLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p109"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code" id="p10code9"><pre class="console" style="font-family:monospace;">$ swipl
Welcome to SWI-Prolog (Multi-threaded, Version 5.6.47)
Copyright (c) 1990-2007 University of Amsterdam.
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
Please visit http://www.swi-prolog.org for details.
&nbsp;
For help, use ?- help(Topic). or ?- apropos(Word).
&nbsp;
?- consult('test_socket.pl').
%     library(error) compiled into error 0.01 sec, 7,508 bytes
%    library(lists) compiled into lists 0.02 sec, 19,312 bytes
%   library(shlib) compiled into shlib 0.02 sec, 34,280 bytes
%  library(socket) compiled into socket 0.02 sec, 40,536 bytes
% test_socket.pl compiled 0.02 sec, 41,872 bytes
&nbsp;
Yes
?- init.</pre></td></tr></table></div>

<p>Then, your server is waiting for connections.<br />
I used telnet to connect to my server :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p10code10'); return false;">View Code</a> CONSOLE</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p1010"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p10code10"><pre class="console" style="font-family:monospace;">$ telnet
telnet&gt; open localhost 2302
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcome on myPrologServer
Connection closed by foreign host.</pre></td></tr></table></div>

<p>You can see that everything works fine. </p>
<p>Using both the socket module and the multithreading module of SWI-Prolog will let you create strong and efficient servers/clients and show everybody that nothing is impossible in Prolog <img src='http://blog.mestan.fr/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>The documentation of the network module is included in SWI-Prolog&#8217;s C-library&#8217;s one, at the following URL : <a href="http://www.swi-prolog.org/packages/clib.html#sec:5">http://www.swi-prolog.org/packages/clib.html#sec:5</a>.</p>
<p>You have now everything needed to write Prolog programs interacting with any servers/clients in the world using the SWI-Prolog C-library&#8217;s socket module !</p>

]]></content:encoded>
			<wfw:commentRss>http://blog.mestan.fr/2008/06/26/network-programming-with-prolog-swi/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Writing User Interfaces in Prolog with XPCE</title>
		<link>http://blog.mestan.fr/2008/06/22/writing-user-interfaces-in-prolog-with-xpce/</link>
		<comments>http://blog.mestan.fr/2008/06/22/writing-user-interfaces-in-prolog-with-xpce/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 19:51:39 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
		
		<category><![CDATA[Prolog]]></category>

		<category><![CDATA[xpce]]></category>

		<guid isPermaLink="false">http://blog.mestan.fr/?p=6</guid>
		<description><![CDATA[Hi,
Writing UIs in Prolog is a very simple thing !
First, with SWI-Prolog, there&#8217;s a dialog editor based on Drag &#38; Drop, like we have for Java, C# or C++, and it generates a prolog-xpce code that we just have to execute to see the window being shown on our screen.
However, we can manually write code [...]]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Writing <strong>UIs</strong> in Prolog is a very simple thing !</p>
<p>First, with <strong>SWI-Prolog</strong>, there&#8217;s a dialog editor based on Drag &amp; Drop, like we have for Java, C# or C++, and it generates a prolog-xpce code that we just have to execute to see the window being shown on our screen.</p>
<p>However, we can manually write code with XPCE predicates.</p>
<p>Just see it in action. Here is a code that shows a 250&#215;100 window with a text label.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6code14'); return false;">View Code</a> PROLOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p614"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p6code14"><pre class="prolog" style="font-family:monospace;"><span style="color: #339933;">:-</span> use<span style="color: #008080;">_module</span><span style="color: #009900;">&#40;</span>library<span style="color: #009900;">&#40;</span>pce<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
my<span style="color: #008080;">_first_program</span> <span style="color: #339933;">:-</span>
	<span style="color: #666666; font-style: italic;">% creates the window</span>
	new<span style="color: #009900;">&#40;</span><span style="color: #008080;">D</span><span style="color: #339933;">,</span> window<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Ma premiere fenetre'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">% resize the window</span>
	send<span style="color: #009900;">&#40;</span><span style="color: #008080;">D</span><span style="color: #339933;">,</span> size<span style="color: #339933;">,</span> size<span style="color: #009900;">&#40;</span><span style="color: #800080;">250</span><span style="color: #339933;">,</span> <span style="color: #800080;">100</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">% creates a textlabel</span>
	new<span style="color: #009900;">&#40;</span><span style="color: #008080;">T</span><span style="color: #339933;">,</span> text<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Hello World !'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">% displays the textlabel at the given point</span>
	send<span style="color: #009900;">&#40;</span><span style="color: #008080;">D</span><span style="color: #339933;">,</span> display<span style="color: #339933;">,</span> <span style="color: #008080;">T</span><span style="color: #339933;">,</span> point<span style="color: #009900;">&#40;</span><span style="color: #800080;">80</span><span style="color: #339933;">,</span> <span style="color: #800080;">40</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	<span style="color: #666666; font-style: italic;">% show the window</span>
	send<span style="color: #009900;">&#40;</span><span style="color: #008080;">D</span><span style="color: #339933;">,</span> <span style="color: #990000;">open</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span></pre></td></tr></table></div>

<p>Save it as <em>xpce.pl</em> for example.</p>
<p>Then, open a terminal. Launch <em>xpce</em>.</p>
<pre>$ xpce
XPCE 6.6.44, October 2007 for i386-linux-gnu and X11R6
Copyright (C) 1993-2007 University of Amsterdam.
XPCE comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
The host-language is SWI-Prolog version 5.6.47

For HELP on prolog, please type help. or apropos(topic).
         on xpce, please type manpce.

?-</pre>
<p>Then just use consult :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6code15'); return false;">View Code</a> PROLOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p615"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p6code15"><pre class="prolog" style="font-family:monospace;"><span style="color: #339933;">?-</span> <span style="color: #990000;">consult</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'xpce.pl'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
<span style="color: #666666; font-style: italic;">% xpce.pl compiled 0.01 sec, 1,280 bytes</span>
&nbsp;
<span style="color: #008080;">Yes</span></pre></td></tr></table></div>

<p>and launch your predicate :</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p6code16'); return false;">View Code</a> PROLOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p616"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p6code16"><pre class="prolog" style="font-family:monospace;"><span style="color: #339933;">?-</span> my<span style="color: #008080;">_first_program</span><span style="color: #339933;">.</span></pre></td></tr></table></div>

<p>You&#8217;ll obtain something like the following image.<br />
<a href="http://blog.mestan.fr/wp-content/xpce.png"><img class="aligncenter size-medium wp-image-7" title="xpce - first program" src="http://blog.mestan.fr/wp-content/xpce.png" alt="First program with XPCE in Prolog" width="268" height="139" /></a></p>
<p>Have fun with XPCE !</p>

]]></content:encoded>
			<wfw:commentRss>http://blog.mestan.fr/2008/06/22/writing-user-interfaces-in-prolog-with-xpce/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Prolog programming language</title>
		<link>http://blog.mestan.fr/2008/06/22/the-prolog-programming-language/</link>
		<comments>http://blog.mestan.fr/2008/06/22/the-prolog-programming-language/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 19:19:46 +0000</pubDate>
		<dc:creator>Alp Mestan</dc:creator>
		
		<category><![CDATA[Prolog]]></category>

		<guid isPermaLink="false">http://blog.mestan.fr/?p=4</guid>
		<description><![CDATA[Maybe you still don&#8217;t know this programming language.
The Prolog programming language permit for example to use logic programming and constraint programming which are uncommon paradigms.
This language is mainly based on the backtracing and unification principles.
If you can read French, you should give a whirl at the following article : Présentation du langage Prolog.
If you can&#8217;t, [...]]]></description>
			<content:encoded><![CDATA[<p>Maybe you still don&#8217;t know this programming language.</p>
<p>The <strong>Prolog</strong> programming language permit for example to use <strong>logic programming</strong> and <strong>constraint programming</strong> which are uncommon paradigms.</p>
<p>This language is mainly based on the <strong>backtracing</strong> and <strong>unification</strong> principles.</p>
<p>If you can read French, you should give a whirl at the following article : <a href="http://pcaboche.developpez.com/article/prolog/presentation/">Présentation du langage Prolog</a>.</p>
<p>If you can&#8217;t, you should give a whirl at this website : <a href="http://www.learnprolognow.org/">Learn Prolog Now !</a>.</p>
<p>A sample code for calculating the size of a list (even if it already exists), in Prolog.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p4code18'); return false;">View Code</a> PROLOG</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p418"><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code" id="p4code18"><pre class="prolog" style="font-family:monospace;">my<span style="color: #008080;">_list_size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #800080;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>
&nbsp;
my<span style="color: #008080;">_list_size</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #008080;">H</span><span style="color: #339933;">|</span><span style="color: #008080;">L</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #008080;">S</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:-</span>
  my<span style="color: #008080;">_list_size</span><span style="color: #009900;">&#40;</span><span style="color: #008080;">L</span><span style="color: #339933;">,</span> <span style="color: #008080;">S1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
  <span style="color: #008080;">S</span> <span style="color: #990000;">is</span> <span style="color: #800080;">1</span><span style="color: #339933;">+</span><span style="color: #008080;">S1</span><span style="color: #339933;">.</span></pre></td></tr></table></div>

<p>My Prolog environment is <strong><em><a href="http://www.swi-prolog.org/">SWI-Prolog</a></em></strong> and I use <a href="http://www.swi-prolog.org/packages/xpce/"><em><strong>SWI-Prolog&#8217;s XPCE</strong></em></a> for User Interfaces.</p>

]]></content:encoded>
			<wfw:commentRss>http://blog.mestan.fr/2008/06/22/the-prolog-programming-language/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

