4 ms·
I’d argue that is not the most ideal Prolog solution. More like it’s simply a recursive implementation of an imperative solution. For fractals you’ll want to b
by rabbits77 1y ago
I’d argue that is not the most ideal Prolog solution. More like it’s simply a recursive implementation of an imperative solution.
For fractals you’ll want to be able to recognize and generate the structures. It’s a great use case for Definite Clause Grammars (DCGs). A perfect example of this would be Triska’s Dragon Curve implementation. https://www.youtube.com/watch?v=DMdiPC1ZckI https://www.youtube.com/watch?v=DMdiPC1ZckI
- taeric 1y agoI would agree. I was actually hoping to be proven wrong with that example. I have yet to see anything other than a constraint program that looks easier to understand in logic programming, sadly.
- taeric 1y agoAdding late to this, as I didn't get to actually look at this video yesterday. I would still agree that you can do better than the examples I'm finding, but I am not entirely clear why/how the dragon curve is honestly any better here? The prolog, notably, does not draw the curve. Just being used to generate the sequence of characters that describes it. But... that is already trivial in normal code. Actually drawing it will get you something like this: https://rosettacode.org/wiki/Dragon_curve#Prolog https://rosettacode.org/wiki/Dragon_curve#Prolog. Contrast that with the Logo version and you can see how the paradigm of the programming language can make a giant difference in how the code solution looks.