Assignments and Projects

Assignments and projects will be posted here.

  • Assignment 1 is available here. This assignment is due on Tuesday, October 7, in the class. Solutions to the assignment are available here
  • Project 1 description is available here. You will need to download this file: unify_lterms.pl. The project is due on Tuesday, November 4th, 5:30 pm. Project 1 FAQ:
    • Q: Are we allowed to declare extra predicates besides the ones that are required in the project?
      A: Yes.
    • Q: How to make Prolog display lists in full (i.e. without ...) ?
      A: Type the following at Prolog prompt:
      ?- set_prolog_flag(toplevel_print_options, [quoted(true), portray(true), max_depth(0)]).
      Now, all lists will be displayed in full. To avoid re-typing this every time you re-start Prolog, create a file called .plrc (pl.ini if you are on Windows) in your working directory, and put the following line into it:
      :- set_prolog_flag(toplevel_print_options, [quoted(true), portray(true), max_depth(0)]).
    • Q: in apply_subst([V/T],...) how to "parse out" V and T ?
      A: As far as Prolog is concerned / is just a name of the atom (operator, to be exact), so all you need to do is to declare you predicate like this:
      apply_subst([V/T], T1, T2) :- some code that uses V and T here.
      Try, this:
      aaa([V/T]) :- write('V is '), write(V), nl, write('T is '), write(T), nl.
      And run a query
      ?- aaa(['X'/[f, 'Y']]).
  • Assignment 2 is available here. This assignment is due on Thursday, February 19, 11:59 pm.
  • My solutions to Assignment 2 are here: stream.ml, append.ml.