<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>This is greek to me. Would you be interested in loading ELinda
and implementing Linda match: using Prolog? I would be <b>*very*</b>
interested to see it!<br>
</p>
<div class="moz-signature">
<div>Have a good one; keep it, light.</div>
<div>Kindly,</div>
<div>rabbit</div>
<div>. .. … ‘…^,^</div>
<br>
<div>Sent from Callisto House :: decentralized mobile homeless
solutions</div>
<br>
<br>
</div>
<div class="moz-cite-prefix">On 10/4/22 18:13, Stéphane Rollandin
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:f60fa5a1-aaee-0b50-3e48-8d5db7ccabd4@zogotounga.net">
<blockquote type="cite">Could this be easily done using Prolog?
<br>
</blockquote>
<br>
Very easily. Prolog is the king of pattern-matching!
<br>
<br>
For example, the append/2 predicate is implemented as
<br>
<br>
logicAppend
<br>
<br>
append([], X, X).
<br>
append([H | X], Y, [H | Z]) :- append(X, Y, Z).
<br>
<br>
and this is the *actual code* for the method #logicAppend in class
Prolog.
<br>
<br>
Now equipped with this, you can do
<br>
<br>
append([a, b], [c, d], List)
<br>
<br>
and you will get the unification (Prolog's uber-notion for
pattern-matching)
<br>
<br>
List = [a,b,c,d].
<br>
<br>
So far, so good. But you can also do
<br>
<br>
append(A, B, [1, 2])
<br>
<br>
which will give you the three ways two lists A and B can be
appended to get [1,2]. The answer will be
<br>
<br>
A = []. B = [1,2].
<br>
A = [1]. B = [2].
<br>
A = [1 2]. B= [].
<br>
<br>
But there is more. You can in fact use any pattern in the
arguments, and unification will tell you what works.
<br>
<br>
For example,
<br>
<br>
append([X | T], [a], [Z, Z, Z])
<br>
<br>
will give you the only way it is possible to append [a] to some [X
| T] (that's a cons cell with car X and cdr T) and get some [Z, Z,
Z] as result (note that only the capitalized terms are variables).
It is:
<br>
<br>
X = a. T = [a]. Z = a
<br>
<br>
The code snippets above can be directly tested in the REPL you get
by evaluating
<br>
<br>
Prolog new openGui
<br>
<br>
Best,
<br>
<br>
Stef
<br>
<br>
</blockquote>
</body>
</html>