1 / 11

Case Study

Case Study. Functional Programming Languages Logic Programming Languages. Functional Languages. There are many functional languages. Scheme Haskell F# ML Lisp Others. Scheme.

terris
Download Presentation

Case Study

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Case Study Functional Programming Languages Logic Programming Languages

  2. Functional Languages • There are many functional languages. • Scheme • Haskell • F# • ML • Lisp • Others

  3. Scheme • Scheme was developed at the MIT AI Lab by Guy L. Steele and Gerald Jay Sussman who introduced it to the academic world via a series of memos • Defining Variable: (define a 10) (+ a 2)

  4. Scheme • Printing : (display "Hello world") • To put new line: (newline) • Arithmetic Expression: (+ 4 6 7)

  5. Scheme • Assignment Statement: (define b 10) (* b 2) (set! b 30)

  6. Scheme (define (greet) (display "Hello, world!") (newline) ) (let ((x 1) (y 2)) (+ x y))

  7. Logic Language • Prolog • Developed at Univ. of Aix-Marseille and Edinburgh in early to mid 1970s • Goal: natural language processing and theorem proving. • Used in Japan’s Fifth Generation Computing Project in 1981

  8. Prolog • Prolog Syntax • Variables are uppercase • constants, predicates are lowercase • List syntax: • [1, 2, 3] • [head | tail] • Program consists of • facts, rules, and goals

  9. Prolog • Facts female(shelley). male(bill). female(mary). male(jake). father(bill, jake). father(bill, shelley). mother(mary, jake). mother(mary, shelley).

  10. Prolog • Rules parent(X, Y) :- mother(X, Y). parent(X, Y) :- father(X, Y). grandparent(X, Z) :- parent(X, Y), parent(Y, Z). sibling(X, Y) :- mother(M, X), mother(M, Y), father(F, X), father(F, Y). ancestor(X, X). ancestor(X, Y) :- parent(X, Z), ancestor(Z, Y)

  11. Prolog • Queries ?- father(bill, jake). yes ?- father(X, jake). X = bill yes ?- father(bill, X). X = jake ; X = shelley yes

More Related