Anybody familiar with prolog?

Discussion in 'Mac Programming' started by npolly0212, Sep 9, 2016.

  1. npolly0212 macrumors 65816

    Joined:
    Sep 21, 2015
    #1
    Hey all,
    Current college student here and have to learn prolog this semester. Wanted to mess around and get ahead and learn it before we actually get into any assignments and I am lost lol.

    I am creating a project for a program where it is dedicated to movies

    I have my movie.pl file with things such as:

    %acted_in(person,movie).
    acted_in(brad_pitt,babel).
    acted_in(cate_blanchette,babel).
    acted_in(sharlto_copley,district_9).
    acted_in(david_james,district_9).

    %directed(person,movie).
    directed(alejandro_inarritu,babel).
    directed(neill_blomkamp,district_9).

    %released(movie,year).
    released(babel,2006).
    released(district_9,2009).


    Those are just some of the ones I have in there. Now my teacher does have stuff up already since he recommended we went ahead and tried our own programs. He went ahead and gave us a makefile that is supposed to work with everything just needed to change the EXE=movie.

    The part where I am lost is on the main.pl. Say I have multiple different questions to put in, how would I add them? Do I just add a writeln with a new question under the previous print_query_false?

    %main.pl
    :- [movie].
    print_query_true(Q) :-
    forall(Q, writeln(true:Q)).
    print_query_false(Q) :-
    forall(\+ Q, writeln(false:Q)).
    main :-
    nl
    writeln( "1. Did Leonardo DiCaprio act in Babel?" ),
    print_query_true(acted_in(leonardo_dicaprio,babel)),
    print_query_false(acted_in(leonardo_dicaprio,babel)),
    nl,
    halt.

    The last problem I have is when i try to run swipl it goes through and turns on the program. but when i type in [movie]. it just says true and doesn't show that is says compiled or anything of the sort.
     
  2. cqexbesd macrumors regular

    Joined:
    Jun 4, 2009

Share This Page