Download
programmeren met algebra n.
Skip this Video
Loading SlideShow in 5 Seconds..
Programmeren met Algebra PowerPoint Presentation
Download Presentation
Programmeren met Algebra

Programmeren met Algebra

153 Vues Download Presentation
Télécharger la présentation

Programmeren met Algebra

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Programmeren met Algebra André van Delft 6 februari 2012 Presentatie op Grotius College Delft

  2. CV • 1979-1985 Studie Wiskunde in Leiden • 1982-1985 Studie Bedrijfskunde in Delft/Rotterdam • 1985-1989 Promotieplaats Informatica in Leiden • 1989-2006 Software-ontwikkelaar op contractbasis • 2006-2012 Wetenschapper bij NATO/NC3A • Onderzoek & Ontwikkeling van Programmeertalen • Parallelisme • Grootheden & Eenheden • Rare talen

  3. Alan Kay

  4. Programmeren moeilijk sinds 1995 • Meerdere taken tegelijk: threading • Hoofdtaak Main thread • Langdurige taken Background thread • Schermafhandeling GUI thread • Gebeurtenissen (event handling) & communicatie • Toetsenbord, muis, touch screen • GPS, sensoren • Internet, Bluetooth • Programmeertalen: C C++Java, C# Scala Geen oplossing…

  5. GUI-applicatie - 1 • Invoerveld • Zoekknop • Zoeken… • Resultaten

  6. GUI-applicatie - 2 valsearchButton = new Button("Go”) { reactions.+= { caseButtonClicked(b) => enabled = false outputTA.text = "Starting search...” new Thread(new Runnable { defrun() { Thread.sleep(3000) SwingUtilities.invokeLater(new Runnable{ defrun() {outputTA.text="Search ready” enabled = true }}) }}).start } }

  7. GUI-applicatie - 3 live = searchSequence... searchSequence = searchCommand showSearchingText searchInDatabase showSearchResults searchCommand= searchButton showSearchingText = @gui: {outputTA.text = "…"} showSearchResults = @gui: {outputTA.text = "…"} searchInDatabase = {* Thread.sleep(3000) *}

  8. GUI-applicatie - 4 • Zoeken: knop of Enter-toets • Afbreken: knop of Escape-toets • Exit: knop of ; daarna: “Are yousure?”… • Alleen zoeken als tekstveld gevuld is • Voortgang tonen

  9. GUI-applicatie - 5 searchGuard = if(!searchTF.text.isEmpty) . anyEvent(comp)  ... searchInDatabase = {*Thread.sleep(3000)*} || progressMonitor progressMonitor = {*Thread.sleep( 250)*} @gui:{searchTF.text+=here.pass} ... live = searchSequence... || exit searchCommand = searchButton + Key.Enter cancelCommand = cancelButton + Key.Escape exitCommand = exitButton+ windowClosing exit = exitCommand@gui: while(!areYouSure) cancelSearch = cancelCommand @gui: showCanceledText searchSequence = searchGuardsearchCommand; showSearchingText searchInDatabase showSearchResults / cancelSearch

  10. Process Algebra Wiskundige theorie over processen Bergstra&Klop, Amsterdam, 1982 x+y = y+x (x+y)+z = x+(y+z) x+x = x (x+y)·z = x·z+y·z (x·y)·z = x·(y·z) O+x = x O·x = O 1·x = x x·1 = x δ+x = x δ·x = δ ε·x = x x·ε = x x y = x y + y x + x|y (x+ε)·y = x·y+ε·y = x·y+y

  11. Werking: Templates & Call Graphs {Hello}+ε; {World} (x+ε)·y = x·y+ε·y = x·y+y

  12. Slot • Eenvoudig en efficiënt • Nu 2000 regels Scala • Nog veel te doen en te ontdekken • Open Source:http://code.google.com/p/subscript/ • www.rosettacode.org …

  13. Hello World http://rosettacode.org/wiki/Hello_world/Text C: #include <stdio.h> intmain(void) { printf(”Hello, World!\n”); return 0; } HQ9+: H C0H: C1R: Hello_world/Text

  14. 100 Doors C: #include <stdio.h> intmain() { int door, square, increment; for(door = 1, square = 1, increment = 1; door <= 100; door++ == square && (square += increment += 2)) printf("door #%d is %s.\n", door, (door == square? "open" : "closed")); return0; } http://rosettacode.org/wiki/100_doors C1R: 100_doors • Stupid • Thismeans thatnearlyevery C1R "solution" in Rosetta is simply a heading, followedby string whichgives the path name to the C solution. Thisis a form of redundancythat is effectively spam. • David St. Hubbins: It's such a fine line betweenstupid, and uh... • Nigel Tufnel: Clever. • David St. Hubbins: Yeah, and clever.

  15. Zeef van Eratosthenes - 1

  16. Zeef van Eratosthenes - 2 main = generator(2,1000000) ==> (..==>sieve) =={toPrint}==> printer generator(s,e) = for(i<-s to e) <=i sieve = =>p:Int? @toPrint:<=p; ..=>i:Int? if (i%p!=0) <=i printer = ..=>i:Int? println,i <==>(i:Int) = {}