Download presentation
Published byBrenda Hart Modified over 8 years ago
1
Functional Programming Languages Logic Programming Languages
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 : To put new line: Arithmetic Expression:
(display "Hello world") To put new line: (newline) Arithmetic Expression: ( )
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
?- father(bill, X). X = jake ; X = shelley
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.