1 / 14

Kapitel 1

Einführung. Kapitel 1. Wat jibt´s denn? Mit Computa kenn´ ick mir aus!. Guten Tag, darf ich Ihnen mal eine Frage stellen?. integers, reals, arrays, records, stacks, files, characters,. Was ist ein „Datentyp“?. „Ein Datentyp

odessa
Download Presentation

Kapitel 1

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. Einführung Kapitel 1 Wat jibt´s denn? Mit Computa kenn´ ick mir aus! Guten Tag, darf ich Ihnen mal eine Frage stellen?

  2. integers, reals, arrays, records, stacks, files, characters, ... Was ist ein „Datentyp“?

  3. „Ein Datentyp legt die Menge der Werte fest, die eine Variable annehmen kann.“ ( Pascal User Manual) Definition erforderlich! Beachte: Nutzerdefinierte Datentypen in vielen Programmiersprachen

  4. Na ja, na ja, ... Zugriffsmechanismen: filo vs. fifo ? stacks = queues alles sequences

  5. ! Datentypen sind Algebren ? • Datentyp: • Menge von Objekten • Operationen über diesen Objekten • = Algebra

  6. Mathematik Algebra = universelle Algebra = algebraische Struktur ------------------ Trägermenge Operationenfamilie Informatik z.B.:real arraybenötigt real, array, integer ------------------ Algebra => Begriff erweitern ! ------------------ mehrere Trägermengen Operationenfamilie Algebra und Informatik

  7. Homogene oder einsortige Algebra Gruppe Monoid Ring Boolesche Algebra Verband Heterogene oder mehrsortige Algebra Datentyp Vektorraum endlicher Automat Syntax einer Programmiersprache Semantik - “ - Algebra und Informatik

  8. Problem: Partialität vieler Operationen: Selektion, Division, Überlauf/Unterlauf, Lesen aus leerem Keller, Aufruf nichtdeklarierter Prozedur mehrsortige, partielle Algebren Theorie kompliziert partielle Operation totale Operation Algebra und Informatik error

  9. Beispiel • Datentyp „Zeichenkeller“ (stacks of characters): • (mindestens) drei Trägermengen • Char= {a, b, c, ..., z} • Stack=Char* • Bool= {true, false} • vier Operationen zweckmäßig • push : Char StackStack • top : StackChar • pop : StackStack • empty? : StackBool

  10. Beispiel (Forts.) Definition der Operationen: Sei  - leerer Keller sx - Füllung (Verkettung) des Kellers s mit Zeichen x push(x,s) = sx top(sx) = x pop(sx) = s true , falls s = empty?(s) =   false , falls s  top() = ? pop() = ?  Einführung von error-Elementen

  11. Beispiel (Forts.) Definition der Operationen: Sei  - leerer Keller sx - Füllung (Verkettung) des Kellers s mit Zeichen x push(x,s) = sx top(sx) = x pop(sx) = s top() = char-err pop() = stack-err true , falls s = empty?(s) = bool-err, falls s = stack-err  false , sonst

  12. Beispiel (Forts.) Trägermengen erweitern: Charp= {a, b, c, ..., z} Char=Charp {char-err} Stack=Charp*  {stack-err} Bool= {true, false}  {bool-err} Operationen - „strikt“ vervollständigen push : Char StackStack top : StackChar pop : StackStack empty? : StackBool

  13. Beispiel (Forts.) • Erweiterung um Boolesche Operationen oft nützlich: • vel : Bool BoolBool • et : Bool BoolBool • non : BoolBool • (alle strikt vervollständigt) • Ergänzung des Datentyps „Zeichenkeller“ um neue Sorte • Int möglich, um z.B. die „Kellertiefe“ zu erfassen: • depth : StackInt • Dann evtl. zweckmäßig, Rechnen über Int hinzuzunehmen: • arithmetische ( +, - ) und Vergleichsoperationen<usw. Algebra mit vier Trägermengen und Operationen zwischen ihnen

  14. Beispiel (Forts.) non empty? top vel Char Stack Bool pop push depth et < - Int + Zeichenkeller Signatur

More Related