News for hackers. Stuff that matters.
Re:CAD Is a Lie: Generative Design to the Rescue by TeMPOraL on Thursday January 14, 2016 @05:54AM (#10900588)
I think it's worth saying explicitly how Prolog does that. It basically runs a DFS on a graph for you. That's it. You can code up a basic Prolog in ~50 lines of Lisp. It's a pretty simple tool.

It's also fascinating to look how people try to use it as a general-purpose programming language. To do that, you have to explicitly hack for the DFS running in the background, the one you were not supposed to know about (from the POV of designing your program) because it's meant to abstract things away. You literally have to do flow control on a graph search algorithm to do things like iteration.

The point being - Prolog is a useful tool, but it's also a very simple one. It won't do magic for you.

Re:CAD Is a Lie: Generative Design to the Rescue by YeGoblynQueenne on Friday January 15, 2016 @04:04AM (#10908083)
Ah, sure, Prolog is dead simple and not a general-purpose language.

Here's a fun little puzzle then. I wrote this predicate:

==

c(A-B, B-T, A-T).

==

That's all the predicate definition - nothing else to it. One line, yeah?

So, you put it in a Prolog source file, consult it, and then fire queries like this:

--

?-c([a,b|A]-A,[c,d|B]-B,T-B).

A = [c, d|B],

T = [a, b, c, d|B].

?- c([a,b|A]-A,[c,d|B]-B,T-[e,f|C]).

A = [c, d, e, f|C],

B = [e, f|C],

T = [a, b, c, d, e, f|C].

?- c([a,b|B]-B, B-T, [a,b,c,d|T]-T).

B = [c, d|T].

?- c((a,b,A)-A,(c,d,B)-B,T-B).

A = (c, d, B),

T = (a, b, c, d, B).

--

Now, based on your understanding of Prolog from ~50 lines of Lisp- how does that predicate work?