140 lines
4.4 KiB
Org Mode
140 lines
4.4 KiB
Org Mode
#+TITLE: Zapiski #1 srečanja programerskega bralnega krožka SICP
|
|
#+AUTHOR: Jurij
|
|
#+OPTIONS: toc:nil num:nil author
|
|
|
|
* Zanimivi izseki
|
|
** str. 9
|
|
#+BEGIN_QUOTE
|
|
Every reader should ask himself periodically "Toward what end, toward what end?" — but do not ask it too often lest you pass up the fun of programming for the constipation of bittersweet philosophy.
|
|
#+END_QUOTE
|
|
|
|
#+begin_quote
|
|
Lisp is a survivor, having been in use for about a quarter of a century.
|
|
#+end_quote
|
|
** str. 11
|
|
#+begin_quote
|
|
It is better to have 100 functions operate on one data structure than to have 10 functions operate on 10 data structures.
|
|
#+end_quote
|
|
** str. 18
|
|
#+begin_quote
|
|
Thus, programs must be written for people to read, and only incidentally for machines to execute.
|
|
#+end_quote
|
|
** str. 19
|
|
#+begin_quote
|
|
Underlying our approach to this subject is our conviction that "computer science" is not a science and that its significance has little to do with computers.
|
|
#+end_quote
|
|
** str. 27
|
|
#+begin_quote
|
|
Finally, we would like to acknowledge the support of the organizations that have encouraged this work over the years, including support from Hewlett-Packard, made possible by Ira Goldstein and Joel Birnbaum, and support from DARPA, made possible by Bob Kahn.
|
|
#+end_quote
|
|
|
|
Bob Kahn je mdr. soavtor protokolov TCP in IP, pionir omreževanja. V DARPA postal kasneje direktor IPTO (Informational Processing Techniques Office), kjer je ustanovil milijardo-dolarski projekt Strategic Copmuting Initiative, največjo investicijo ameriške federalne vlade v računalništvo ever ('83 do '93) - razvijali so proizvodnjo čipov in umetne inteligence. Ustrašili so se japoncev, podobno kot v 50ih sovjetov.
|
|
|
|
Po DARPA ustanovil CNRI (corporation for national research initiatives), neprofitno organizacijo kjer je delal tudi guido van rossum (avtor pythona). Tam so izdali python verzije 1.3 do 1.6 ter GNU mailman.
|
|
|
|
Preko očeta v sorodu s fizikom Hermanom Kahnom, ki je napisal knjigo o tem kako bi amerika lahko zmagala nuklearno vojno in postal inspiracija za dr. Strangelove-a v znanem Kubrickovem filmu. Ustanovil je Hudson institut, konzervativni think tank ki je začel pri premišljevanju hladnovojnih scenarijev in se razširil na polja ekonomije, zdravstva, šolstva in gemblanja. Delal je tudi v RAND korporaciji, močnem hladnovojnem inštitutu, vpletenem v vietnamsko vojno, iraško vojno, danes pa kuri "AI apokaliptični" scenarij.
|
|
|
|
** str. 77
|
|
Stoy 1977
|
|
* Vaje
|
|
** 1.1 Kaj vrnejo izrazi?
|
|
- 10
|
|
- 12
|
|
- 8
|
|
- 3
|
|
- 6
|
|
- /
|
|
- /
|
|
- 19
|
|
- #f
|
|
- 4
|
|
- 16
|
|
- 6
|
|
- 16
|
|
|
|
** 1.2 Pretvori izraz v prefix obliko
|
|
#+begin_src scheme :exports both
|
|
(/ (+ 5 4
|
|
(- 2
|
|
(- 3
|
|
(+ 6
|
|
1/3))))
|
|
(* 3
|
|
(- 6 2)
|
|
(- 2 7)))
|
|
#+end_src
|
|
|
|
#+RESULTS:
|
|
: -43/180
|
|
** 1.3 procedura, ki prejme 3 argumente in vrne vsoto kvadratov vecjih dveh
|
|
|
|
#+begin_src scheme :exports both :results table
|
|
(define (vsota-vecjih-kvadratov a b c)
|
|
(cond ((<= a b c) (+ (* b b) (* c c)))
|
|
((<= b a c) (+ (* a a) (* c c)))
|
|
(else (+ (* b b) (* a a)))))
|
|
;; ^ NAROBE! <= primerja vse tri stevilke, ne prvo z drugima dvema oz. ostalimi
|
|
|
|
(define (+kvadrat a b) (+ (* a a) (* b b)))
|
|
(define (vsota-vecjih-kvadratov2 a b c)
|
|
(if (>= a b)
|
|
(if (>= b c)
|
|
(+kvadrat a b)
|
|
(+kvadrat a c))
|
|
(if (>= a c)
|
|
(+kvadrat a b)
|
|
(+kvadrat b c))))
|
|
|
|
(list
|
|
'("Pricakovano" 85 41 164 89)
|
|
|
|
(list "Funkcija1"
|
|
(vsota-vecjih-kvadratov 6 1 7)
|
|
(vsota-vecjih-kvadratov 3 4 5)
|
|
(vsota-vecjih-kvadratov 8 10 2)
|
|
(vsota-vecjih-kvadratov 3 8 5))
|
|
|
|
(list "Funkcija2"
|
|
(vsota-vecjih-kvadratov2 6 1 7)
|
|
(vsota-vecjih-kvadratov2 3 4 5)
|
|
(vsota-vecjih-kvadratov2 8 10 2)
|
|
(vsota-vecjih-kvadratov2 3 8 5)))
|
|
#+end_src
|
|
|
|
#+RESULTS:
|
|
| Pricakovano | 85 | 41 | 164 | 89 |
|
|
| Funkcija1 | 85 | 41 | 164 | 73 |
|
|
| Funkcija2 | 85 | 41 | 164 | 89 |
|
|
|
|
** 1.4 Opis procedure
|
|
#+begin_src scheme
|
|
(define (a-plus-abs-b a b)
|
|
((if (> b 0) + -) a b))
|
|
#+end_src
|
|
|
|
Izraz ~if~ vrne funkcijo ~+~ ali ~-~ , glede na to, ali je argument ~b~ večji ali manjši od 0.
|
|
|
|
Če je ~b~ manjši od 0, ga odšteje od ~a~, sicer pa ga prišeje. Zato je rezultat funkcije ekvivalenten vsoti ~a~ in absolutni vrednosti ~b~.
|
|
|
|
** 1.5 Aplikativni red in normalni red evalvacije
|
|
|
|
#+begin_src scheme
|
|
(define (p) (p))
|
|
|
|
(define (test x y)
|
|
(if (= x 0)
|
|
0
|
|
y))
|
|
|
|
;; Evalvira:
|
|
(test 0 (p))
|
|
#+end_src
|
|
|
|
TODO!
|
|
|
|
** 1.6 TODO
|
|
|
|
** 1.7 TODO
|
|
|
|
** 1.8 TODO
|