Comparative Languages Spring 2005
Homework 2, 4th Quarter
Prolog worksheet (see Xerox copy)

  1. Affordable Journeys
  2. Acyclic Directed Graph
  3. Member
    member(X,[X|T]).
    member(X,[H|T]) :- member(X,T).
    
    /*
    1. In ther first clause, what is the T for?
    2. In the second clause, what is the H for?
    3. What do the following goals do (what is the first answer if any,
    and then what are the subsequent answers if any on backtracking?
    
    ?-member(john,[paul,john]).
    ?-member(X,[paul,john]).
    ?-member(joc,[marx,darwin,freud]).
    ?-member(foo,X).
    */
    
    mystery(X,A,B) :- member(X,A), member(X,B).
    
    /*
    4. What do the following goals do?
    ?-mystery(a,[b,c,a],[p,a,l]).
    ?-mystery(b,[b,l,u,e],[y,e,l,l,o,w]).
    ?-mystery(X,[r,a,p,i,d],[a,c,t,i,o,n]).
    ?-mystery(X,[w,a,l,n,u,t],[c,h,e,r,r,y]).
    
    5. The first clause of member may be written with an anonymous variable.
    member(X,[X|_]).
    
    How may the second clause of member be written with an anonymous variable?
    
    
    Assignments Spring 05
  4. Language examples
  5. GNU Smalltalk language reference (for Squeak, type "inisqueak")
  6. Prolog programs
  7. Language links
  8. Leif's Programming language page, home page Smalltalk material, Smalltalk assignment (card game)
  9. UCSD, PINT, Course
  10. CIS400 Programming Languages, U Mich Dearborn
  11. CS 3304 VaTech

  12. GMU CS 363
  13. Compilers + Dragon book, Comp 663
  14. Syntax and Semantics of Programming Languages online text, and the Course Programming Language Foundations