Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was going through this recently because my brother is going through the CS program that I went through, which is the only time I've encountered anyone mention Prolog. I still can't really envision how to create comprehensive systems in this, but it seems the logic paradigm could be applied to some really useful new areas that it hasn't reached yet, similar to how the influence of functional languages is pretty much expected for any trendy new language today (Rust, ES6).


I think it helps to think of Prolog as something similar to SQL. See, for example, https://stackoverflow.com/questions/2117651/comparing-sql-an....


It doesn't really help to think that way. The accepted answer to that StackOverflow question sounds very much like the poster didn't really know what Prolog is (and possibly confused it with Datalog).

Here is code to append two lists in Prolog:

    append([], Xs, Xs).
    append([X|Xs], Ys, [X|Zs]) :-
        append(Xs, Ys, Zs).
You can use this as follows ("?-" is the user input prompt, equations are the system's answers):

    ?- append([a,b], [c,d], Zs).
    Zs = [a, b, c, d].


    ?- append(Xs, Ys, [a,b,c]).
    Xs = [],Ys = [a, b, c] ;
    Xs = [a],Ys = [b, c];
    Xs = [a, b],Ys = [c];
    Xs = [a, b, c],Ys = [].
How would you express the notion of lists in SQL? How would you express the notion of appending two lists? And how would you express the notion of searching for all possible pairs of lists that, when appended, yield the list [a,b,c]?


> the influence of functional languages is pretty much expected for any trendy new language today (Rust

Rust is barely influenced by functional languages.


>Rust is barely influenced by functional languages.

That is arguable. Rust supports and in a lot of ways prefers functional solutions for problems, for example the iterator trait in std and a gazillion similar library APIs. Functional programming works very well with Rust's type system.


for expert system prolog is the king


Yes. But others (like Haskell) aren't much behind.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: