534 lines
24 KiB
HTML
534 lines
24 KiB
HTML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
|
<head>
|
|
<!-- 2024-04-30 Tue 19:31 -->
|
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Structure and Interpretation of Computer Programs</title>
|
|
<meta name="author" content="Lio Novelli" />
|
|
<meta name="generator" content="Org Mode" />
|
|
<style>
|
|
#content { max-width: 60em; margin: auto; }
|
|
.title { text-align: center;
|
|
margin-bottom: .2em; }
|
|
.subtitle { text-align: center;
|
|
font-size: medium;
|
|
font-weight: bold;
|
|
margin-top:0; }
|
|
.todo { font-family: monospace; color: red; }
|
|
.done { font-family: monospace; color: green; }
|
|
.priority { font-family: monospace; color: orange; }
|
|
.tag { background-color: #eee; font-family: monospace;
|
|
padding: 2px; font-size: 80%; font-weight: normal; }
|
|
.timestamp { color: #bebebe; }
|
|
.timestamp-kwd { color: #5f9ea0; }
|
|
.org-right { margin-left: auto; margin-right: 0px; text-align: right; }
|
|
.org-left { margin-left: 0px; margin-right: auto; text-align: left; }
|
|
.org-center { margin-left: auto; margin-right: auto; text-align: center; }
|
|
.underline { text-decoration: underline; }
|
|
#postamble p, #preamble p { font-size: 90%; margin: .2em; }
|
|
p.verse { margin-left: 3%; }
|
|
pre {
|
|
border: 1px solid #e6e6e6;
|
|
border-radius: 3px;
|
|
background-color: #f2f2f2;
|
|
padding: 8pt;
|
|
font-family: monospace;
|
|
overflow: auto;
|
|
margin: 1.2em;
|
|
}
|
|
pre.src {
|
|
position: relative;
|
|
overflow: auto;
|
|
}
|
|
pre.src:before {
|
|
display: none;
|
|
position: absolute;
|
|
top: -8px;
|
|
right: 12px;
|
|
padding: 3px;
|
|
color: #555;
|
|
background-color: #f2f2f299;
|
|
}
|
|
pre.src:hover:before { display: inline; margin-top: 14px;}
|
|
/* Languages per Org manual */
|
|
pre.src-asymptote:before { content: 'Asymptote'; }
|
|
pre.src-awk:before { content: 'Awk'; }
|
|
pre.src-authinfo::before { content: 'Authinfo'; }
|
|
pre.src-C:before { content: 'C'; }
|
|
/* pre.src-C++ doesn't work in CSS */
|
|
pre.src-clojure:before { content: 'Clojure'; }
|
|
pre.src-css:before { content: 'CSS'; }
|
|
pre.src-D:before { content: 'D'; }
|
|
pre.src-ditaa:before { content: 'ditaa'; }
|
|
pre.src-dot:before { content: 'Graphviz'; }
|
|
pre.src-calc:before { content: 'Emacs Calc'; }
|
|
pre.src-emacs-lisp:before { content: 'Emacs Lisp'; }
|
|
pre.src-fortran:before { content: 'Fortran'; }
|
|
pre.src-gnuplot:before { content: 'gnuplot'; }
|
|
pre.src-haskell:before { content: 'Haskell'; }
|
|
pre.src-hledger:before { content: 'hledger'; }
|
|
pre.src-java:before { content: 'Java'; }
|
|
pre.src-js:before { content: 'Javascript'; }
|
|
pre.src-latex:before { content: 'LaTeX'; }
|
|
pre.src-ledger:before { content: 'Ledger'; }
|
|
pre.src-lisp:before { content: 'Lisp'; }
|
|
pre.src-lilypond:before { content: 'Lilypond'; }
|
|
pre.src-lua:before { content: 'Lua'; }
|
|
pre.src-matlab:before { content: 'MATLAB'; }
|
|
pre.src-mscgen:before { content: 'Mscgen'; }
|
|
pre.src-ocaml:before { content: 'Objective Caml'; }
|
|
pre.src-octave:before { content: 'Octave'; }
|
|
pre.src-org:before { content: 'Org mode'; }
|
|
pre.src-oz:before { content: 'OZ'; }
|
|
pre.src-plantuml:before { content: 'Plantuml'; }
|
|
pre.src-processing:before { content: 'Processing.js'; }
|
|
pre.src-python:before { content: 'Python'; }
|
|
pre.src-R:before { content: 'R'; }
|
|
pre.src-ruby:before { content: 'Ruby'; }
|
|
pre.src-sass:before { content: 'Sass'; }
|
|
pre.src-scheme:before { content: 'Scheme'; }
|
|
pre.src-screen:before { content: 'Gnu Screen'; }
|
|
pre.src-sed:before { content: 'Sed'; }
|
|
pre.src-sh:before { content: 'shell'; }
|
|
pre.src-sql:before { content: 'SQL'; }
|
|
pre.src-sqlite:before { content: 'SQLite'; }
|
|
/* additional languages in org.el's org-babel-load-languages alist */
|
|
pre.src-forth:before { content: 'Forth'; }
|
|
pre.src-io:before { content: 'IO'; }
|
|
pre.src-J:before { content: 'J'; }
|
|
pre.src-makefile:before { content: 'Makefile'; }
|
|
pre.src-maxima:before { content: 'Maxima'; }
|
|
pre.src-perl:before { content: 'Perl'; }
|
|
pre.src-picolisp:before { content: 'Pico Lisp'; }
|
|
pre.src-scala:before { content: 'Scala'; }
|
|
pre.src-shell:before { content: 'Shell Script'; }
|
|
pre.src-ebnf2ps:before { content: 'ebfn2ps'; }
|
|
/* additional language identifiers per "defun org-babel-execute"
|
|
in ob-*.el */
|
|
pre.src-cpp:before { content: 'C++'; }
|
|
pre.src-abc:before { content: 'ABC'; }
|
|
pre.src-coq:before { content: 'Coq'; }
|
|
pre.src-groovy:before { content: 'Groovy'; }
|
|
/* additional language identifiers from org-babel-shell-names in
|
|
ob-shell.el: ob-shell is the only babel language using a lambda to put
|
|
the execution function name together. */
|
|
pre.src-bash:before { content: 'bash'; }
|
|
pre.src-csh:before { content: 'csh'; }
|
|
pre.src-ash:before { content: 'ash'; }
|
|
pre.src-dash:before { content: 'dash'; }
|
|
pre.src-ksh:before { content: 'ksh'; }
|
|
pre.src-mksh:before { content: 'mksh'; }
|
|
pre.src-posh:before { content: 'posh'; }
|
|
/* Additional Emacs modes also supported by the LaTeX listings package */
|
|
pre.src-ada:before { content: 'Ada'; }
|
|
pre.src-asm:before { content: 'Assembler'; }
|
|
pre.src-caml:before { content: 'Caml'; }
|
|
pre.src-delphi:before { content: 'Delphi'; }
|
|
pre.src-html:before { content: 'HTML'; }
|
|
pre.src-idl:before { content: 'IDL'; }
|
|
pre.src-mercury:before { content: 'Mercury'; }
|
|
pre.src-metapost:before { content: 'MetaPost'; }
|
|
pre.src-modula-2:before { content: 'Modula-2'; }
|
|
pre.src-pascal:before { content: 'Pascal'; }
|
|
pre.src-ps:before { content: 'PostScript'; }
|
|
pre.src-prolog:before { content: 'Prolog'; }
|
|
pre.src-simula:before { content: 'Simula'; }
|
|
pre.src-tcl:before { content: 'tcl'; }
|
|
pre.src-tex:before { content: 'TeX'; }
|
|
pre.src-plain-tex:before { content: 'Plain TeX'; }
|
|
pre.src-verilog:before { content: 'Verilog'; }
|
|
pre.src-vhdl:before { content: 'VHDL'; }
|
|
pre.src-xml:before { content: 'XML'; }
|
|
pre.src-nxml:before { content: 'XML'; }
|
|
/* add a generic configuration mode; LaTeX export needs an additional
|
|
(add-to-list 'org-latex-listings-langs '(conf " ")) in .emacs */
|
|
pre.src-conf:before { content: 'Configuration File'; }
|
|
|
|
table { border-collapse:collapse; }
|
|
caption.t-above { caption-side: top; }
|
|
caption.t-bottom { caption-side: bottom; }
|
|
td, th { vertical-align:top; }
|
|
th.org-right { text-align: center; }
|
|
th.org-left { text-align: center; }
|
|
th.org-center { text-align: center; }
|
|
td.org-right { text-align: right; }
|
|
td.org-left { text-align: left; }
|
|
td.org-center { text-align: center; }
|
|
dt { font-weight: bold; }
|
|
.footpara { display: inline; }
|
|
.footdef { margin-bottom: 1em; }
|
|
.figure { padding: 1em; }
|
|
.figure p { text-align: center; }
|
|
.equation-container {
|
|
display: table;
|
|
text-align: center;
|
|
width: 100%;
|
|
}
|
|
.equation {
|
|
vertical-align: middle;
|
|
}
|
|
.equation-label {
|
|
display: table-cell;
|
|
text-align: right;
|
|
vertical-align: middle;
|
|
}
|
|
.inlinetask {
|
|
padding: 10px;
|
|
border: 2px solid gray;
|
|
margin: 10px;
|
|
background: #ffffcc;
|
|
}
|
|
#org-div-home-and-up
|
|
{ text-align: right; font-size: 70%; white-space: nowrap; }
|
|
textarea { overflow-x: auto; }
|
|
.linenr { font-size: smaller }
|
|
.code-highlighted { background-color: #ffff00; }
|
|
.org-info-js_info-navigation { border-style: none; }
|
|
#org-info-js_console-label
|
|
{ font-size: 10px; font-weight: bold; white-space: nowrap; }
|
|
.org-info-js_search-highlight
|
|
{ background-color: #ffff00; color: #000000; font-weight: bold; }
|
|
.org-svg { }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div id="content" class="content">
|
|
<h1 class="title">Structure and Interpretation of Computer Programs</h1>
|
|
<div id="table-of-contents" role="doc-toc">
|
|
<h2>Table of Contents</h2>
|
|
<div id="text-table-of-contents" role="doc-toc">
|
|
<ul>
|
|
<li><a href="#orgfa6dfd2">1. Foreword and Preface</a></li>
|
|
<li><a href="#org7c75cdc">2. 1. Grajenje abstrakcij s procedurami</a>
|
|
<ul>
|
|
<li><a href="#org5fd76f1">2.1. Elementi programiranja</a></li>
|
|
<li><a href="#orgdd9a89f">2.2. Izvajanje kombinacij(e)</a></li>
|
|
<li><a href="#orgc00fe8a">2.3. 1.1.4 Sestavljene procedure</a></li>
|
|
<li><a href="#org880c70f">2.4. 1.1.5 Substitucijski model za izvajanje procedur</a></li>
|
|
<li><a href="#orgc3d2732">2.5. meta</a>
|
|
<ul>
|
|
<li><a href="#org4f46a86">2.5.1. video lekcije</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#org9170e9c">2.6. vaje</a>
|
|
<ul>
|
|
<li><a href="#org33d53b7">2.6.1. 1.3</a></li>
|
|
<li><a href="#orgaece15c">2.6.2. 1.5</a></li>
|
|
<li><a href="#orgfcdfec0">2.6.3. 1.6</a></li>
|
|
<li><a href="#org6d81d53">2.6.4. 1.7</a></li>
|
|
<li><a href="#orgec5d243">2.6.5. 1.8</a></li>
|
|
</ul>
|
|
</li>
|
|
<li><a href="#org8d4a90a">2.7. 1.1.8 Procedure kot crne skatle abstrakcij</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgfa6dfd2" class="outline-2">
|
|
<h2 id="orgfa6dfd2"><span class="section-number-2">1.</span> Foreword and Preface</h2>
|
|
<div class="outline-text-2" id="text-1">
|
|
<blockquote>
|
|
<p>
|
|
Lisp je preživeli, v uporabi je že "polovico stoletja".
|
|
</p>
|
|
</blockquote>
|
|
|
|
<blockquote>
|
|
<p>
|
|
The discretionary exportable functionality entrusted to the individual Lisp programmer
|
|
is more than an order of magniture greater than that to be found within Pascal enterprises.
|
|
</p>
|
|
</blockquote>
|
|
|
|
<blockquote>
|
|
<p>
|
|
Želimo vzpostaviti idejo, da programski jezik ni samo način, da računalnik izvaja operacije,
|
|
ampak da je predvsem nov formalni medij za izražanje idej o metodologiji. Zato morajo biti
|
|
programi napisani predvsem zato, da jih ljudje berejo, in slučajno, da jih izvajajo računalniki.
|
|
</p>
|
|
|
|
<p>
|
|
Bistvena tema ni sintaksa določenih struktur v programskem jeziku, niti …, temveč tehnike
|
|
nadzora intelektualne kompleksnosti veliki programskih sistemov.
|
|
</p>
|
|
</blockquote>
|
|
|
|
<blockquote>
|
|
<p>
|
|
Naš pristop k temi izvira iz prepričanja, da "computer science" ni znanost in da ima njen
|
|
pomen bolj malo opraviti z računalniki. Računalniška revolucija je revolucija v načinu
|
|
mišljenja in izražanju idej. Bistvo teh sprememb najbolše opiše pojem
|
|
<span class="underline">proceduralne epistemologije</span>, ki se ukvarja s strukturo vednosti z imperativnega stališča
|
|
za razliko od klasične matematike, ki je bolj deklerativna. Matematika postavi okvir za
|
|
natančno spoprijemanje s pojmovanjem "kaj je". Računanje pa ponudi okvir za natančno
|
|
ukvarjanje s pojmovanjem "kako".
|
|
</p>
|
|
</blockquote>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org7c75cdc" class="outline-2">
|
|
<h2 id="org7c75cdc"><span class="section-number-2">2.</span> 1. Grajenje abstrakcij s procedurami</h2>
|
|
<div class="outline-text-2" id="text-2">
|
|
</div>
|
|
<div id="outline-container-org5fd76f1" class="outline-3">
|
|
<h3 id="org5fd76f1"><span class="section-number-3">2.1.</span> Elementi programiranja</h3>
|
|
<div class="outline-text-3" id="text-2-1">
|
|
<dl class="org-dl">
|
|
<dt>Primitivni izrazi</dt><dd>predstavtljajo najpreprostejše gradnike (entitete)
|
|
programskega jezika</dd>
|
|
<dt>Načini kombinacije,</dt><dd>s katerimi so sestavljeni elementi zgrajeni iz
|
|
preprostejših</dd>
|
|
<dt>Načini abstrakcije,</dt><dd>s katerimi so lahko sestavljeni elementi poimenovani in
|
|
omogočajo upravljanje z njimii kot enotami</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgdd9a89f" class="outline-3">
|
|
<h3 id="orgdd9a89f"><span class="section-number-3">2.2.</span> Izvajanje kombinacij(e)</h3>
|
|
<div class="outline-text-3" id="text-2-2">
|
|
<p>
|
|
Postopek za izvajanje kombinacij:
|
|
</p>
|
|
<ol class="org-ol">
|
|
<li>Izvedi podizraz kombinacije.</li>
|
|
<li>Uporabi/uveljavi proceduro, ki je najbolje levi podizraz (operator) z
|
|
argumenti, ki so vrednosti drugih podizrazov (operandi).</li>
|
|
</ol>
|
|
|
|
<p>
|
|
Postopek evalvacije je rekurziven, saj drugi korak v sebi vključuje prvega,
|
|
oziroma vključuje svojo definicijo.
|
|
</p>
|
|
|
|
<p>
|
|
Tako se zgradi akumulacijsko drevo. Na koncu vedno prideš do točke, ko izvajaš
|
|
primitivne izraze, ki so:
|
|
</p>
|
|
<ul class="org-ul">
|
|
<li>vrednosti numeričnih števk, ki jo označujejo.</li>
|
|
<li>vrednosti vgrajenih operatorjev so strojni ukazi sekvenc, ki izvedejo te
|
|
operacije.</li>
|
|
<li>vrednosti drugih imen so objekti asociirani s temi imeni v okolju.</li>
|
|
</ul>
|
|
|
|
<p>
|
|
Drugo pravilo je poseben primer tretjega pravila. Simboli + in * so tudi
|
|
vključeni v globalno okolje in so asociirani s strojnimi ukazi, ki so njihove
|
|
vrednosti. <b>Pomembno je prepoznati vlogo okolja pri določanju pomena simbolov v
|
|
izrazih.</b>
|
|
</p>
|
|
|
|
<p>
|
|
To pravilo se ne nanaša na <span class="underline">posebne oblike (special forms)</span>. <code>define</code> je posebna
|
|
oblika.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="outline-container-orgc00fe8a" class="outline-3">
|
|
<h3 id="orgc00fe8a"><span class="section-number-3">2.3.</span> 1.1.4 Sestavljene procedure</h3>
|
|
<div class="outline-text-3" id="text-2-3">
|
|
<ul class="org-ul">
|
|
<li>Številke in aritmetične operacije so primitivni podatki in procedure.</li>
|
|
<li>Gnezdenje kombinacij omogoča način za združevanje operacij.</li>
|
|
<li>Definicije, ki asociirajo imena z vrednostmi omogočajo omejene načine
|
|
abstrakcije.</li>
|
|
</ul>
|
|
|
|
<p>
|
|
<code>(define (square x) (* x x))</code>
|
|
</p>
|
|
|
|
<p>
|
|
<code>(define square (lambda (x) (* x x)))</code>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org880c70f" class="outline-3">
|
|
<h3 id="org880c70f"><span class="section-number-3">2.4.</span> 1.1.5 Substitucijski model za izvajanje procedur</h3>
|
|
<div class="outline-text-3" id="text-2-4">
|
|
<p>
|
|
Za izvajanje sestavljenih procedur z argumenti, izvedeš telo procedure z vsakim
|
|
formalnim parametrom, ki ga nadomestiš s pripadajočim argumentom.
|
|
</p>
|
|
|
|
<p>
|
|
<span class="underline">ergh, tukaj se zapletam s slovenskimi prevodi</span>
|
|
</p>
|
|
|
|
<p>
|
|
<span class="underline">kaj je application in kaj evaluation?</span>
|
|
</p>
|
|
|
|
<p>
|
|
Načini, na katere deluje interpreter (prevajalnik):
|
|
</p>
|
|
<dl class="org-dl">
|
|
<dt>Aplikativni vrstni red</dt><dd>Najprej evalviraj operator in operande, potem pa
|
|
izvedi proizvedeno proceduro s pridobljenimi argumenti.</dd>
|
|
<dt>Normalni vrstni red</dt><dd>Ne izvajaj operandov dokler njihove vrednost niso
|
|
potrebne. Najprej zamenjaj izraze operandov s parametri, dokler ne pride do
|
|
izraza, ki vsebuje zgolj primitivne izraze in potem izvedi (vso) evalvacijo.</dd>
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div id="outline-container-orgc3d2732" class="outline-3">
|
|
<h3 id="orgc3d2732"><span class="section-number-3">2.5.</span> meta</h3>
|
|
<div class="outline-text-3" id="text-2-5">
|
|
<p>
|
|
Linki:
|
|
<a href="https://develop.spacemacs.org/layers/+lang/scheme/README.html">https://develop.spacemacs.org/layers/+lang/scheme/README.html</a>
|
|
<a href="https://www.nongnu.org/geiser/">https://www.nongnu.org/geiser/</a>
|
|
<a href="https://www.gnu.org/software/guile/learn/">https://www.gnu.org/software/guile/learn/</a>
|
|
<a href="https://spritely.institute/static/papers/scheme-primer.html#introduction">https://spritely.institute/static/papers/scheme-primer.html#introduction</a>
|
|
</p>
|
|
|
|
<p>
|
|
Kako nastavit spacemacs, in malo o guile-u.
|
|
</p>
|
|
</div>
|
|
|
|
|
|
<div id="outline-container-org4f46a86" class="outline-4">
|
|
<h4 id="org4f46a86"><span class="section-number-4">2.5.1.</span> video lekcije</h4>
|
|
<div class="outline-text-4" id="text-2-5-1">
|
|
<p>
|
|
<a href="https://yewtu.be/channel/UCEBb1b_L6zDS3xTUrIALZOw">https://yewtu.be/channel/UCEBb1b_L6zDS3xTUrIALZOw</a> (6.001 SICP: Structure and Interpretation of Computer Programs (2004))
|
|
<a href="https://yewtu.be/playlist?list=PL7BcsI5ueSNFPCEisbaoQ0kXIDX9rR5FF">https://yewtu.be/playlist?list=PL7BcsI5ueSNFPCEisbaoQ0kXIDX9rR5FF</a> (MIT 6.001 Structure and Interpretation, 1986)
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org9170e9c" class="outline-3">
|
|
<h3 id="org9170e9c"><span class="section-number-3">2.6.</span> vaje</h3>
|
|
<div class="outline-text-3" id="text-2-6">
|
|
</div>
|
|
<div id="outline-container-org33d53b7" class="outline-4">
|
|
<h4 id="org33d53b7"><span class="section-number-4">2.6.1.</span> 1.3</h4>
|
|
<div class="outline-text-4" id="text-2-6-1">
|
|
</div>
|
|
<ol class="org-ol">
|
|
<li><a id="orge132dac"></a>najprej narobe<br />
|
|
<div class="outline-text-5" id="text-2-6-1-1">
|
|
<p>
|
|
Define a procedure that takes three numbers as arguments and returns the sum of
|
|
the squares of the two larger numbers.
|
|
</p>
|
|
|
|
<div class="org-src-container">
|
|
<pre class="src src-scheme"><span style="color: #4f97d7;">(</span><span style="color: #4f97d7; font-weight: bold;">define</span> <span style="color: #bc6ec5;">(</span><span style="color: #bc6ec5; font-weight: bold;">sum-of-large</span> x y z<span style="color: #bc6ec5;">)</span>
|
|
<span style="color: #bc6ec5;">(</span>+
|
|
<span style="color: #2d9574;">(</span><span style="color: #4f97d7; font-weight: bold;">if</span> <span style="color: #67b11d;">(</span>> x y<span style="color: #67b11d;">)</span> <span style="color: #67b11d;">(</span>* x x<span style="color: #67b11d;">)</span> <span style="color: #67b11d;">(</span>* y y<span style="color: #67b11d;">)</span><span style="color: #2d9574;">)</span>
|
|
<span style="color: #2d9574;">(</span><span style="color: #4f97d7; font-weight: bold;">if</span> <span style="color: #67b11d;">(</span>> y z<span style="color: #67b11d;">)</span> <span style="color: #67b11d;">(</span>* y y<span style="color: #67b11d;">)</span> <span style="color: #67b11d;">(</span>* z z<span style="color: #67b11d;">)</span><span style="color: #2d9574;">)</span>
|
|
<span style="color: #bc6ec5;">)</span>
|
|
<span style="color: #4f97d7;">)</span>
|
|
<span style="color: #4f97d7;">(</span>sum-of-large <span style="color: #a45bad;">3</span> <span style="color: #a45bad;">8</span> <span style="color: #a45bad;">5</span><span style="color: #4f97d7;">)</span>
|
|
</pre>
|
|
</div>
|
|
|
|
<div class="org-src-container">
|
|
<pre class="src src-scheme"><span style="color: #4f97d7;">(</span><span style="color: #4f97d7; font-weight: bold;">define</span> <span style="color: #bc6ec5;">(</span><span style="color: #bc6ec5; font-weight: bold;">sum-of-larger</span> x y z<span style="color: #bc6ec5;">)</span> <span style="color: #bc6ec5;">(</span><span style="color: #4f97d7; font-weight: bold;">let*</span>
|
|
<span style="color: #2d9574;">(</span><span style="color: #67b11d;">(</span>s <span style="color: #b1951d;">(</span><span style="color: #4f97d7; font-weight: bold;">lambda</span> <span style="color: #4f97d7;">(</span>a<span style="color: #4f97d7;">)</span> <span style="color: #4f97d7;">(</span>* a a<span style="color: #4f97d7;">)</span><span style="color: #b1951d;">)</span><span style="color: #67b11d;">)</span>
|
|
<span style="color: #67b11d;">(</span>sl <span style="color: #b1951d;">(</span><span style="color: #4f97d7; font-weight: bold;">lambda</span> <span style="color: #4f97d7;">(</span>b c<span style="color: #4f97d7;">)</span> <span style="color: #4f97d7;">(</span><span style="color: #4f97d7; font-weight: bold;">if</span> <span style="color: #bc6ec5;">(</span>> b c<span style="color: #bc6ec5;">)</span> <span style="color: #bc6ec5;">(</span>s b<span style="color: #bc6ec5;">)</span> <span style="color: #bc6ec5;">(</span>s c<span style="color: #bc6ec5;">)</span><span style="color: #4f97d7;">)</span><span style="color: #b1951d;">)</span><span style="color: #67b11d;">)</span>
|
|
<span style="color: #2d9574;">)</span>
|
|
<span style="color: #2d9574;">(</span>+ <span style="color: #67b11d;">(</span>sl x y<span style="color: #67b11d;">)</span> <span style="color: #67b11d;">(</span>sl y z<span style="color: #67b11d;">)</span><span style="color: #2d9574;">)</span>
|
|
<span style="color: #bc6ec5;">)</span><span style="color: #4f97d7;">)</span>
|
|
<span style="color: #4f97d7;">(</span>sum-of-larger <span style="color: #a45bad;">3</span> <span style="color: #a45bad;">8</span> <span style="color: #a45bad;">5</span><span style="color: #4f97d7;">)</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
|
|
<li><a id="org8da2665"></a>pravilno<br />
|
|
<div class="outline-text-5" id="text-2-6-1-2">
|
|
<div class="org-src-container">
|
|
<pre class="src src-scheme"><span style="color: #4f97d7;">(</span><span style="color: #4f97d7; font-weight: bold;">define</span> <span style="color: #bc6ec5;">(</span><span style="color: #bc6ec5; font-weight: bold;">sum-squares-of-larger</span> x y z<span style="color: #bc6ec5;">)</span>
|
|
<span style="color: #bc6ec5;">(</span><span style="color: #4f97d7; font-weight: bold;">if</span> <span style="color: #2d9574;">(</span>> x y<span style="color: #2d9574;">)</span>
|
|
<span style="color: #2d9574;">(</span><span style="color: #4f97d7; font-weight: bold;">if</span> <span style="color: #67b11d;">(</span>> y z<span style="color: #67b11d;">)</span>
|
|
<span style="color: #67b11d;">(</span>+ <span style="color: #b1951d;">(</span>* x x<span style="color: #b1951d;">)</span> <span style="color: #b1951d;">(</span>* y y<span style="color: #b1951d;">)</span><span style="color: #67b11d;">)</span>
|
|
<span style="color: #67b11d;">(</span>+ <span style="color: #b1951d;">(</span>* x x<span style="color: #b1951d;">)</span> <span style="color: #b1951d;">(</span>* z z<span style="color: #b1951d;">)</span><span style="color: #67b11d;">)</span>
|
|
<span style="color: #2d9574;">)</span>
|
|
<span style="color: #2d9574;">(</span><span style="color: #4f97d7; font-weight: bold;">if</span> <span style="color: #67b11d;">(</span>> x z<span style="color: #67b11d;">)</span>
|
|
<span style="color: #67b11d;">(</span>+ <span style="color: #b1951d;">(</span>* y y<span style="color: #b1951d;">)</span> <span style="color: #b1951d;">(</span>* x x<span style="color: #b1951d;">)</span><span style="color: #67b11d;">)</span>
|
|
<span style="color: #67b11d;">(</span>+ <span style="color: #b1951d;">(</span>* y y<span style="color: #b1951d;">)</span> <span style="color: #b1951d;">(</span>* z z<span style="color: #b1951d;">)</span><span style="color: #67b11d;">)</span>
|
|
<span style="color: #2d9574;">)</span>
|
|
<span style="color: #bc6ec5;">)</span>
|
|
<span style="color: #4f97d7;">)</span>
|
|
<span style="color: #4f97d7;">(</span>sum-squares-of-larger <span style="color: #a45bad;">9</span> <span style="color: #a45bad;">10</span> <span style="color: #a45bad;">8</span><span style="color: #4f97d7;">)</span>
|
|
</pre>
|
|
</div>
|
|
</div>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
<div id="outline-container-orgaece15c" class="outline-4">
|
|
<h4 id="orgaece15c"><span class="section-number-4">2.6.2.</span> 1.5</h4>
|
|
<div class="outline-text-4" id="text-2-6-2">
|
|
<p>
|
|
Aplikativni vrstni red: pade takoj v neskoncno zanko.
|
|
Normalni vrstni red: izvrsi test in pride v if, ki ne izvrsi drugega dela.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgfcdfec0" class="outline-4">
|
|
<h4 id="orgfcdfec0"><span class="section-number-4">2.6.3.</span> 1.6</h4>
|
|
<div class="outline-text-4" id="text-2-6-3">
|
|
<p>
|
|
<a href="sqrt-newton.scm">sqrt-newton.scm</a>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org6d81d53" class="outline-4">
|
|
<h4 id="org6d81d53"><span class="section-number-4">2.6.4.</span> 1.7</h4>
|
|
<div class="outline-text-4" id="text-2-6-4">
|
|
<ul class="org-ul">
|
|
<li><code>good-enough?</code> ni vredu za iskanje korenov majhnih stevil.</li>
|
|
<li>pravtako za zelo velika stevila</li>
|
|
<li>napisi alternativno <code>good-enough?</code> proceduro, ki bo gledala, kdaj so spremembe
|
|
dovolj majhne in takrat prekini funkcijo.</li>
|
|
</ul>
|
|
|
|
<p>
|
|
// Poglej v sqrt-newton.scm
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-orgec5d243" class="outline-4">
|
|
<h4 id="orgec5d243"><span class="section-number-4">2.6.5.</span> 1.8</h4>
|
|
<div class="outline-text-4" id="text-2-6-5">
|
|
<p>
|
|
// Glej v sqrt-newton.sqm
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="outline-container-org8d4a90a" class="outline-3">
|
|
<h3 id="org8d4a90a"><span class="section-number-3">2.7.</span> 1.1.8 Procedure kot crne skatle abstrakcij</h3>
|
|
<div class="outline-text-3" id="text-2-7">
|
|
<ul class="org-ul">
|
|
<li>block structure</li>
|
|
<li>lexical scoping</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |