• Keine Ergebnisse gefunden

 Object-Oriented Languages  Logic Languages  Procedural Languages  Functional Languages Imperative Languages Declarative Languages Overview

N/A
N/A
Protected

Academic year: 2021

Aktie " Object-Oriented Languages  Logic Languages  Procedural Languages  Functional Languages Imperative Languages Declarative Languages Overview"

Copied!
8
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Overview

Imperative Languages

 sequence of instructions, executed after each other

Procedural Languages

 variables, assignments, control structures

Object-Oriented Languages

 objects and classes

 ADT and inheritance

Declarative Languages

 specify what should be computed

 compiler determines how the computation works

Functional Languages

 no side-effects

 recursion

Logic Languages

 rules to define relations

(2)

Important Programming Languages

object-oriented

procedural functional logic

Fortran

PL/1 Algol 68 1950

1960

1970

C

Simula

C++

Java Ada-95

Lisp

Scheme ML Miranda

Prolog Smalltalk

Eiffel

Modula-3

1980

1990

Cobol Algol 60

Pascal

Ada

Haskell

2000

Python

Scala

(3)

Facts and Queries

klaus susanne

dominique aline

werner monika gerd renate

karin peter

female(monika).

female(karin).

female(renate).

female(susanne).

female(aline).

married(werner, monika).

married(gerd, renate).

married(klaus, susanne).

male(werner).

male(klaus).

male(gerd).

male(peter).

male(dominique).

motherOf(monika, karin).

motherOf(monika, klaus).

motherOf(renate, susanne).

motherOf(renate, peter).

motherOf(susanne, aline).

motherOf(susanne, dominique).

Program:

?- male(gerd).

true

?- married(gerd, monika).

false

?- human(gerd).

true

human(X).

(4)

Variables in Queries

klaus susanne

dominique aline

werner monika gerd renate

karin peter

female(monika).

female(aline). ...

married(werner, monika).

married(klaus, susanne)....

male(werner).

male(dominique)....

motherOf(monika, karin).

motherOf(susanne, dominique)....

Program:

?- motherOf(X, susanne).

X = renate

?- motherOf(renate, Y).

Y = susanne ;

Y = peter

(5)

Combined Queries

klaus susanne

dominique aline

werner monika gerd renate

karin peter

Program:

?- married(gerd,W), motherOf(W,susanne).

W = renate

?- motherOf(Grandma,Mom), motherOf(Mom,aline).

Grandma = renate Mom = susanne

female(monika).

female(aline). ...

married(werner, monika).

married(klaus, susanne)....

male(werner).

male(dominique)....

motherOf(monika, karin).

motherOf(susanne, dominique)....

(6)

Rules

klaus susanne

dominique aline

werner monika gerd renate

karin peter

Program:

fatherOf(F,C) :- married(F,W), motherOf(W,C).

?- fatherOf(gerd, susanne).

true

?- fatherOf(gerd, Y).

Y = susanne ; Y = peter

female(monika).

female(aline). ...

married(werner, monika).

married(klaus, susanne)....

male(werner).

male(dominique)....

motherOf(monika, karin).

motherOf(susanne, dominique)....

(7)

Several Rules for one Predicate

klaus susanne

dominique aline

werner monika gerd renate

karin peter

Program:

parent(X, Y) :- motherOf(X,Y).

parent(X, Y) :- fatherOf(X,Y).

?- parent(X, susanne).

female(monika).

female(aline). ...

married(werner, monika).

married(klaus, susanne)....

male(werner).

male(dominique)....

motherOf(monika, karin).

motherOf(susanne, dominique)....

X = renate ; X = gerd

fatherOf(F,C) :- married(F,W), motherOf(W,C).

(8)

Recursive Rules

klaus susanne

dominique aline

werner monika gerd renate

karin peter

Program:

parent(X, Y) :- motherOf(X,Y).

parent(X, Y) :- fatherOf(X,Y).

?- ancestor(X, aline).

female(monika).

married(klaus, susanne)....

male (werner).

motherOf(susanne, dominique)....

X = susanne ; X = monika

fatherOf(F,C) :- married(F,W), motherOf(W,C).

ancestor(V,X) :- parent(V,X).

ancestor(V,X) :- parent(V,Y), ancestor(Y,X).

X = klaus ;

; X = renate ; X = werner ; X = gerd

Referenzen

ÄHNLICHE DOKUMENTE

[r]

Spezifische Lösung: DSL I Maßgeschneiderte Sprache I Wohldefinierte Unterklasse (Domäne) von Problemen I Geringer Abstand zum Problem I Als Teil

Spezifische Lösung: DSL I Maßgeschneiderte Sprache I Wohldefinierte Unterklasse (Domäne) von Problemen I Geringer Abstand zum Problem I Domain-Specific Language. (DSL) I Als

I Axiomatic semantics tries to give a meaning of a programming construct by giving proof rules. This means we have to put them into relation with each other, and show that

160) The list of reserved identifiers with external linkage includes errno, math_errhandling, setjmp, and va_end... the header, so if a library function is declared explicitly when

7 The declarator in a function definition specifies the name of the function being defined and the identifiers of its parameters. If the declarator includes a parameter type list,

Gabriele R¨ oger (University of Basel) Theory of Computer Science March 15, 2021 5 / 29?. Repetition:

Is it then possible to detect, among those only, the string representations of tree documents valid with respect to d.. Try to formalize a notion of weak validation capturing the