2024-04-30 19:33:52 +02:00
<?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-08-21 21:38:05 +02:00
<!-- 2024 - 08 - 21 Wed 21:37 -->
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< li > < a href = "#org8f9019d" > Foreword and Preface< / a > < / li >
< li > < a href = "#org8da94f0" > 1. Grajenje abstrakcij s procedurami< / a >
2024-04-30 19:33:52 +02:00
< ul >
2024-08-21 21:38:05 +02:00
< li > < a href = "#org2d8c589" > 1.1. Elementi programiranja< / a > < / li >
< li > < a href = "#org22f68a2" > 1.2. Izvajanje kombinacij(e)< / a > < / li >
< li > < a href = "#orgebf2f25" > 1.3. Sestavljene procedure< / a > < / li >
< li > < a href = "#orgdffc490" > 1.4. Substitucijski model za izvajanje procedur< / a > < / li >
< li > < a href = "#orgf927aa9" > 1.5. meta< / a >
2024-04-30 19:33:52 +02:00
< ul >
2024-08-21 21:38:05 +02:00
< li > < a href = "#orgaf6b74a" > 1.5.1. video lekcije< / a > < / li >
2024-04-30 19:33:52 +02:00
< / ul >
< / li >
2024-08-21 21:38:05 +02:00
< li > < a href = "#orgfe799a1" > 1.6. vaje< / a >
2024-04-30 19:33:52 +02:00
< ul >
2024-08-21 21:38:05 +02:00
< li > < a href = "#org65283e4" > 1.6.1. 1.3< / a > < / li >
< li > < a href = "#org01b57a1" > 1.6.2. 1.5< / a > < / li >
< li > < a href = "#orgd9ada7f" > 1.6.3. 1.6< / a > < / li >
< li > < a href = "#orge35dcc6" > 1.6.4. 1.7< / a > < / li >
< li > < a href = "#org06ffcf1" > 1.6.5. 1.8< / a > < / li >
2024-06-10 01:04:10 +02:00
< / ul >
< / li >
2024-08-21 21:38:05 +02:00
< li > < a href = "#orgbfe073a" > 1.7. 1.1.8 Procedure kot crne skatle abstrakcij< / a > < / li >
< li > < a href = "#orgd7f3af9" > 1.8. 1.2.2 Drevesna rekurzija< / a > < / li >
< li > < a href = "#org03a5d43" > 1.9. 1.2.3 Redi rasti< / a > < / li >
< li > < a href = "#orge040934" > 1.10. 1.2.4 Eksponentna funkcija< / a > < / li >
< li > < a href = "#org0a8ec75" > 1.11. Najvecji skupni deljitel< / a > < / li >
< li > < a href = "#org1dd31b6" > 1.12. Primer: Iskanje prastevil< / a > < / li >
< li > < a href = "#org7555a3a" > 1.13. 1.3 Sestavljanje abstrakcij s procedurami visjega reda< / a > < / li >
< li > < a href = "#orgabdfef2" > 1.14. 1.3.1 Procedure kot argumenti< / a > < / li >
< li > < a href = "#orga3d1bae" > 1.15. 1.3.2 Sestavljanje procedur z < code > Lambda< / code > < / a > < / li >
< li > < a href = "#org7ddef27" > 1.16. 1.3.3 Procedure kot splosne metode< / a > < / li >
< li > < a href = "#org6e12126" > 1.17. 1.3.4 Procedure kot vrnjene vrednosti< / a > < / li >
2024-06-10 01:04:10 +02:00
< / ul >
< / li >
2024-08-21 21:38:05 +02:00
< li > < a href = "#orge2a3918" > 2. Grajenje absrakcij s podatki< / a >
2024-06-10 01:04:10 +02:00
< ul >
2024-08-21 21:38:05 +02:00
< li > < a href = "#org4ed7803" > 2.1. Uvod v podatkovne abstrakcije< / a >
2024-06-10 01:04:10 +02:00
< ul >
2024-08-21 21:38:05 +02:00
< li > < a href = "#org3f47737" > 2.1.1. Aritmeticne operacije z racionalnimi stevili< / a > < / li >
< li > < a href = "#orgfeee81c" > 2.1.2. Pregrade abstrakcij< / a > < / li >
< li > < a href = "#org50ad531" > 2.1.3. Kaj so podatki?< / a > < / li >
< li > < a href = "#org8f92707" > 2.1.4. razsirjena vaja: aritmetika z intervali< / a > < / li >
< / ul >
< / li >
< li > < a href = "#org324d412" > 2.2. Hierarhični podatki in lastnosti zaprtosti< / a >
< ul >
< li > < a href = "#org2fa71cc" > 2.2.1. Reprezentacija sekvenc< / a > < / li >
2024-04-30 19:33:52 +02:00
< / ul >
< / li >
< / ul >
< / li >
< / ul >
< / div >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org8f9019d" class = "outline-2" >
< h2 id = "org8f9019d" > Foreword and Preface< / h2 >
< div class = "outline-text-2" id = "text-org8f9019d" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org8da94f0" class = "outline-2" >
< h2 id = "org8da94f0" > < span class = "section-number-2" > 1.< / span > Grajenje abstrakcij s procedurami< / h2 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-2" id = "text-1" >
2024-04-30 19:33:52 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org2d8c589" class = "outline-3" >
< h3 id = "org2d8c589" > < span class = "section-number-3" > 1.1.< / span > Elementi programiranja< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-1" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org22f68a2" class = "outline-3" >
< h3 id = "org22f68a2" > < span class = "section-number-3" > 1.2.< / span > Izvajanje kombinacij(e)< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-2" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgebf2f25" class = "outline-3" >
< h3 id = "orgebf2f25" > < span class = "section-number-3" > 1.3.< / span > Sestavljene procedure< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-3" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgdffc490" class = "outline-3" >
< h3 id = "orgdffc490" > < span class = "section-number-3" > 1.4.< / span > Substitucijski model za izvajanje procedur< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-4" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgf927aa9" class = "outline-3" >
< h3 id = "orgf927aa9" > < span class = "section-number-3" > 1.5.< / span > meta< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-5" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgaf6b74a" class = "outline-4" >
< h4 id = "orgaf6b74a" > < span class = "section-number-4" > 1.5.1.< / span > video lekcije< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-1-5-1" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgfe799a1" class = "outline-3" >
< h3 id = "orgfe799a1" > < span class = "section-number-3" > 1.6.< / span > vaje< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-6" >
2024-04-30 19:33:52 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org65283e4" class = "outline-4" >
< h4 id = "org65283e4" > < span class = "section-number-4" > 1.6.1.< / span > 1.3< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-1-6-1" >
2024-04-30 19:33:52 +02:00
< / div >
< ol class = "org-ol" >
2024-08-21 21:38:05 +02:00
< li > < a id = "org9dc9c1d" > < / a > najprej narobe< br / >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-5" id = "text-1-6-1-1" >
2024-04-30 19:33:52 +02:00
< 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" >
2024-05-29 21:54:05 +02:00
< 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 >
2024-04-30 19:33:52 +02:00
< / pre >
< / div >
< div class = "org-src-container" >
2024-05-29 21:54:05 +02:00
< 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 >
2024-04-30 19:33:52 +02:00
< 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 >
2024-05-29 21:54:05 +02:00
< 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 >
2024-04-30 19:33:52 +02:00
< / pre >
< / div >
< / div >
< / li >
2024-08-21 21:38:05 +02:00
< li > < a id = "org64f7ccc" > < / a > pravilno< br / >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-5" id = "text-1-6-1-2" >
2024-04-30 19:33:52 +02:00
< div class = "org-src-container" >
2024-05-29 21:54:05 +02:00
< 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 >
2024-04-30 19:33:52 +02:00
< 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 >
2024-05-29 21:54:05 +02:00
< 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 >
2024-04-30 19:33:52 +02:00
< 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 >
2024-05-29 21:54:05 +02:00
< 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 >
2024-04-30 19:33:52 +02:00
< / pre >
< / div >
< / div >
< / li >
< / ol >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org01b57a1" class = "outline-4" >
< h4 id = "org01b57a1" > < span class = "section-number-4" > 1.6.2.< / span > 1.5< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-1-6-2" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgd9ada7f" class = "outline-4" >
< h4 id = "orgd9ada7f" > < span class = "section-number-4" > 1.6.3.< / span > 1.6< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-1-6-3" >
2024-04-30 19:33:52 +02:00
< p >
< a href = "sqrt-newton.scm" > sqrt-newton.scm< / a >
< / p >
< / div >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orge35dcc6" class = "outline-4" >
< h4 id = "orge35dcc6" > < span class = "section-number-4" > 1.6.4.< / span > 1.7< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-1-6-4" >
2024-04-30 19:33:52 +02:00
< 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 >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org06ffcf1" class = "outline-4" >
< h4 id = "org06ffcf1" > < span class = "section-number-4" > 1.6.5.< / span > 1.8< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-1-6-5" >
2024-04-30 19:33:52 +02:00
< p >
// Glej v sqrt-newton.sqm
< / p >
< / div >
< / div >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgbfe073a" class = "outline-3" >
< h3 id = "orgbfe073a" > < span class = "section-number-3" > 1.7.< / span > 1.1.8 Procedure kot crne skatle abstrakcij< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-7" >
2024-04-30 19:33:52 +02:00
< ul class = "org-ul" >
< li > block structure< / li >
< li > lexical scoping< / li >
< / ul >
< / div >
< / div >
2024-05-16 22:33:30 +02:00
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgd7f3af9" class = "outline-3" >
< h3 id = "orgd7f3af9" > < span class = "section-number-3" > 1.8.< / span > 1.2.2 Drevesna rekurzija< / h3 >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org03a5d43" class = "outline-3" >
< h3 id = "org03a5d43" > < span class = "section-number-3" > 1.9.< / span > 1.2.3 Redi rasti< / h3 >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orge040934" class = "outline-3" >
< h3 id = "orge040934" > < span class = "section-number-3" > 1.10.< / span > 1.2.4 Eksponentna funkcija< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-10" >
< p >
Tukaj se naucimu successive squaring, ki potem se veckrat prav pride.
< / p >
2024-05-29 21:54:05 +02:00
< p >
#name: exponent
< / p >
< div class = "org-src-container" >
< pre class = "src src-scheme" > < span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > O(n) korakov in O(n) prostora< / span >
< 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;" > expt< / span > b n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > = n < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 1< / span >
< span style = "color: #2d9574;" > (< / span > * b < span style = "color: #67b11d;" > (< / span > expt b < span style = "color: #b1951d;" > (< / span > - n < span style = "color: #a45bad;" > 1< / span > < 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > expt-i< / span > b n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > expt-iter b n < span style = "color: #a45bad;" > 1< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > O(n) korakov O(1) prostor< / span >
< 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;" > expt-iter< / span > b cnt prod< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > = cnt < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
prod
< span style = "color: #2d9574;" > (< / span > expt-iter b < span style = "color: #67b11d;" > (< / span > - cnt < span style = "color: #a45bad;" > 1< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > * b prod< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > fast-expt< / span > b n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = n < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > even? n< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > square < span style = "color: #b1951d;" > (< / span > fast-expt b < span style = "color: #4f97d7;" > (< / span > / n < span style = "color: #a45bad;" > 2< / 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: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #67b11d;" > (< / span > * b < span style = "color: #b1951d;" > (< / span > fast-expt b < span style = "color: #4f97d7;" > (< / span > - n < span style = "color: #a45bad;" > 1< / span > < span style = "color: #4f97d7;" > )< / span > < 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > even?< / span > n< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > = < span style = "color: #2d9574;" > (< / span > remainder n < span style = "color: #a45bad;" > 2< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > square< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > * x x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > 1.16< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > successive squaring (fast-expt) but with iteration.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > transformation (* a (expt b n)) constant< / span >
< 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;" > fast-expt-i< / span > b n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > fast-expt-iter b n < span style = "color: #a45bad;" > 1< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > fast-expt-iter< / span > b n a< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = n < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > a< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > even? n< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > fast-expt-iter < span style = "color: #b1951d;" > (< / span > square b< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > / n < span style = "color: #a45bad;" > 2< / span > < span style = "color: #b1951d;" > )< / span > a< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #67b11d;" > (< / span > fast-expt-iter b < span style = "color: #b1951d;" > (< / span > - n < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * a b< 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > I'm not sure why this works. I was just guessing.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > excersize 1.17< / span >
< 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;" > slow-multi< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > = b < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 0< / span >
2024-08-21 21:38:05 +02:00
< span style = "color: #2d9574;" > (< / span > + a < span style = "color: #67b11d;" > (< / span > slow-multi a < span style = "color: #b1951d;" > (< / span > - b < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
2024-05-29 21:54:05 +02:00
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > halve< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > / x < span style = "color: #a45bad;" > 2< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > double< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > * x < span style = "color: #a45bad;" > 2< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > fast-multi< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = b < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > even? b< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > double < span style = "color: #b1951d;" > (< / span > fast-multi a < span style = "color: #4f97d7;" > (< / span > halve b< 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: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #67b11d;" > (< / span > + a < span style = "color: #b1951d;" > (< / span > fast-multi a < span style = "color: #4f97d7;" > (< / span > - b < span style = "color: #a45bad;" > 1< / span > < span style = "color: #4f97d7;" > )< / span > < 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > excersize 1.18< / span >
2024-08-21 21:38:05 +02:00
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Russian paesant method - zelo star algoritem.< / span >
2024-05-29 21:54:05 +02:00
< 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;" > fast-multi-i< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > fast-multi-iter a b < span style = "color: #a45bad;" > 0< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > fast-multi-iter< / span > a b s< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = b < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > s< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > even? b< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > fast-multi-iter < span style = "color: #b1951d;" > (< / span > double a< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > halve b< span style = "color: #b1951d;" > )< / span > s< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #67b11d;" > (< / span > fast-multi-iter a < span style = "color: #b1951d;" > (< / span > - b < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > + s a< 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 >
2024-06-10 01:04:10 +02:00
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > excercise 1.19 - fast fibnonachi< / span >
< 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;" > fast-fibo< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > fast-fibo-iter < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #a45bad;" > 1< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > fast-fibo-iter< / span > a b p q count< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = count < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > b< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > even? count< span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > fast-fibo-iter
a
b
< span style = "color: #b1951d;" > (< / span > + < span style = "color: #4f97d7;" > (< / span > * p p< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > * q q< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span >
< span style = "color: #b1951d;" > (< / span > + < span style = "color: #4f97d7;" > (< / span > * q q< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > * < span style = "color: #a45bad;" > 2< / span > p q< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span >
< span style = "color: #b1951d;" > (< / span > / count < span style = "color: #a45bad;" > 2< / span > < 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;" > else< / span > < span style = "color: #67b11d;" > (< / span > fast-fibo-iter
< span style = "color: #b1951d;" > (< / span > + < span style = "color: #4f97d7;" > (< / span > * b q< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > * a q< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > * a p< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span >
< span style = "color: #b1951d;" > (< / span > + < span style = "color: #4f97d7;" > (< / span > * b p< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > * a q< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span >
p
q
< span style = "color: #b1951d;" > (< / span > - count < span style = "color: #a45bad;" > 1< / span > < 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > p' = q^2 + 2pq< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > p' = p^2 + q^2< / span >
< 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;" > slow-fibo< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = n < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > = n < span style = "color: #a45bad;" > 1< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #67b11d;" > (< / span > +
< span style = "color: #b1951d;" > (< / span > slow-fibo < span style = "color: #4f97d7;" > (< / span > - n < span style = "color: #a45bad;" > 1< / span > < span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span >
< span style = "color: #b1951d;" > (< / span > slow-fibo < span style = "color: #4f97d7;" > (< / span > - n < span style = "color: #a45bad;" > 2< / span > < span style = "color: #4f97d7;" > )< / span > < 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > melje melje in melje . fast-fibo iypljune takoj< / span >
2024-05-29 21:54:05 +02:00
< / pre >
< / div >
< / div >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org0a8ec75" class = "outline-3" >
< h3 id = "org0a8ec75" > < span class = "section-number-3" > 1.11.< / span > Najvecji skupni deljitel< / h3 >
< div class = "outline-text-3" id = "text-1-11" >
< p >
Evklidov algoritem je zelo star algoritem.
< / p >
< p >
Ce je < code > r< / code > ostanek pri deljenju < code > a< / code > z < code > b< / code > , potem so skupni deljitelji < code > a< / code > in < code > b< / code >
enaki kot skupni deljitelji kot < code > b< / code > in < code > r< / code > .
< / p >
< p >
< b > Lamejev teorem< / b > :: Ce evklidov algoritem potrebuje < code > k< / code > korakov, da izracuna NSD
nekega para, potem mora biti manjsa stevilka v paru vecja ali enaka < code > k< / code > -ti
Fibonaccijevi stevilki.
< / p >
< p >
< b > footnote< / b > Gabriel Lame - francoski matematik rojen 1845, ki je postavil veliko
tez, ampak nobene ni dokazal.
< / p >
< p >
Lamejev teorem lahko uporabis za ocen velikosti rasti evklidovega algoritma:
< code > n > = Fib(k) =. fi^k/sqrt(5)< / code > . Torej stevilo korako rase logaritemsko.
< / 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;" > gcd< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > = b < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
a
< span style = "color: #2d9574;" > (< / span > gcd b < span style = "color: #67b11d;" > (< / span > remainder a b< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 1.20< / span >
< / pre >
< / div >
< / div >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org1dd31b6" class = "outline-3" >
< h3 id = "org1dd31b6" > < span class = "section-number-3" > 1.12.< / span > Primer: Iskanje prastevil< / h3 >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org7555a3a" class = "outline-3" >
< h3 id = "org7555a3a" > < span class = "section-number-3" > 1.13.< / span > 1.3 Sestavljanje abstrakcij s procedurami visjega reda< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-13" >
2024-05-29 21:54:05 +02:00
< p >
Procedure, ki spreminjajo druge procedure se imenujejo < b > procedure višjega reda< / b > .
< / p >
< / div >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgabdfef2" class = "outline-3" >
< h3 id = "orgabdfef2" > < span class = "section-number-3" > 1.14.< / span > 1.3.1 Procedure kot argumenti< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-14" >
2024-05-29 21:54:05 +02:00
< p >
Primer vsote.
< / p >
< div class = "org-src-container" >
< pre class = "src src-guile" >
< / pre >
< / div >
2024-05-16 22:33:30 +02:00
< p >
//exercise 1.29
#name: simpson
< / p >
< div class = "org-src-container" >
2024-05-29 21:54:05 +02:00
< 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< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > > a b< span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 0< / span >
2024-05-16 22:33:30 +02:00
< span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > term a< span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > sum term < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > next b< span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
2024-05-29 21:54:05 +02:00
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > integral< / span > f a b dx< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > add-dx< / span > x< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > + x dx< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > * < span style = "color: #2d9574;" > (< / span > sum f < span style = "color: #67b11d;" > (< / span > + a < span style = "color: #b1951d;" > (< / span > / dx < span style = "color: #a45bad;" > 2.0< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > add-dx b< span style = "color: #2d9574;" > )< / span > dx< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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-s< / span > term a next b fact< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > fact is altering between 4 and 2< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > check-fact< / span > fact< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #67b11d;" > (< / span > = fact < span style = "color: #a45bad;" > 4< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 4< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > > a b< span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 0< / span >
2024-05-16 22:33:30 +02:00
< span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > * fact < span style = "color: #b1951d;" > (< / span > term a< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > sum-s term < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > next b < span style = "color: #b1951d;" > (< / span > check-fact fact< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
2024-05-29 21:54:05 +02:00
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > simpson< / span > f a b dx< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > add-dx< / span > x< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > + x dx< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > * < span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > f a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > f b< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > sum-s f < span style = "color: #b1951d;" > (< / span > add-dx a< span style = "color: #b1951d;" > )< / span > add-dx < span style = "color: #b1951d;" > (< / span > - b dx< span style = "color: #b1951d;" > )< / span > < span style = "color: #a45bad;" > 4< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > / dx < span style = "color: #a45bad;" > 3.0< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > simpson-gizmo< / span > f a b dx< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > add-dxdx< / span > x< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > + x dx dx< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > * < span style = "color: #2d9574;" > (< / span > +
< span style = "color: #67b11d;" > (< / span > * < span style = "color: #a45bad;" > 4< / span > < span style = "color: #b1951d;" > (< / span > sum f < span style = "color: #4f97d7;" > (< / span > + a dx< span style = "color: #4f97d7;" > )< / span > add-dxdx b< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > * < span style = "color: #a45bad;" > 2< / span > < span style = "color: #b1951d;" > (< / span > sum f a add-dxdx b< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
2024-05-16 22:33:30 +02:00
< span style = "color: #67b11d;" > (< / span > - < span style = "color: #b1951d;" > (< / span > f a< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > - < span style = "color: #b1951d;" > (< / span > f b< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
2024-05-29 21:54:05 +02:00
< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > / dx < span style = "color: #a45bad;" > 3.0< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > cube< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > * x x x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > list
< span style = "color: #bc6ec5;" > (< / span > integral cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 0.01< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > integral cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 0.001< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > simpson cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 0.01< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > simpson cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 0.001< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > simpson cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #2d9574;" > (< / span > / < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 1000< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > simpson-gizmo cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 0.01< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > simpson-gizmo cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #2d9574;" > (< / span > / < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 10000< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
2024-08-21 21:38:05 +02:00
< span style = "color: #bc6ec5;" > (< / span > simpson-gizmo cube < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 0.0001< / span > < span style = "color: #bc6ec5;" > )< / span >
2024-05-29 21:54:05 +02:00
< span style = "color: #4f97d7;" > )< / span >
2024-05-16 22:33:30 +02:00
< / pre >
< / div >
< p >
// exercise 1.30
< / p >
< div class = "org-src-container" >
2024-05-29 21:54:05 +02:00
< 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-i< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > iter< / span > a result< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #67b11d;" > (< / span > > a b< span style = "color: #67b11d;" > )< / span >
2024-05-16 22:33:30 +02:00
result
2024-05-29 21:54:05 +02:00
< span style = "color: #67b11d;" > (< / span > iter < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > + result < span style = "color: #4f97d7;" > (< / span > term a< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
2024-05-16 22:33:30 +02:00
< span style = "color: #2d9574;" > )< / span >
2024-05-29 21:54:05 +02:00
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > iter a < span style = "color: #a45bad;" > 0< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
2024-05-16 22:33:30 +02:00
< / pre >
< / div >
2024-05-29 21:54:05 +02:00
< p >
// excercise 1.30, 1.31. 1.32
< / p >
< div class = "org-src-container" >
< pre class = "src src-scheme" > < span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Analogno napisi produkt kot vsoto.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Pokazi kako izgleda fakulteta.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Aproksimacija pi/4 = 2/3*4/3*4/5*6/5*6/7*8/7...< / span >
< 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;" > produkt-r< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > a, b sta spodnja in zgornja meja< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > > a b< span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 1< / span >
< span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > term a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > produkt-r term < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > next b< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > fakulteta-p< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > produkt-r < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > x< span style = "color: #67b11d;" > )< / span > x< span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > + x < span style = "color: #a45bad;" > 1< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > pribl-pi< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > produkt-r < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > / < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > - a < span style = "color: #a45bad;" > 1.0< / span > < span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > + a < span style = "color: #a45bad;" > 1.0< / span > < span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * a a< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 3.0< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > + x < span style = "color: #a45bad;" > 2.0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
n
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > gizmo se je spomnil resitve - dva produkta (zgornji in spodnji)< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > iterativni produkt-i< / span >
< 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;" > produkt-i< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > iter-p< / span > a result< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #67b11d;" > (< / span > > a b< span style = "color: #67b11d;" > )< / span >
result
< span style = "color: #67b11d;" > (< / span > iter-p < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * result < span style = "color: #4f97d7;" > (< / span > term a< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > iter-p a < span style = "color: #a45bad;" > 1< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > pribl-pi-term< / span > a< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > / < span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > - a < span style = "color: #a45bad;" > 1.0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > + a < span style = "color: #a45bad;" > 1< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > * a a< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > pribl-pi-next< / span > a< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > + a < span style = "color: #a45bad;" > 2.0< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > pribl-pii< / span > n< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > produkt-i
pribl-pi-term
< span style = "color: #a45bad;" > 3.0< / span >
pribl-pi-next
n
< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
2024-06-10 01:04:10 +02:00
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > excercise 1.32< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > recursive accumulate< / span >
< 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;" > accumulate-r< / span > combiner null-val term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > combiner is a procedure of two arguments.< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > > a b< span style = "color: #2d9574;" > )< / span >
null-val
< span style = "color: #2d9574;" > (< / span > combiner < span style = "color: #67b11d;" > (< / span > term a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > accumulate-r combiner null-val term < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > next b< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > sum-combiner< / span > t acc< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > + t acc< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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-a< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > accumulate-r < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > t acc< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > + t acc< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 0< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > prod-a< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > accumulate-r < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > t acc< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > * t acc< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 1< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > accumulate-i< / span > combiner null-val term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Iterative accumulator.< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > iter-a< / span > a result< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #67b11d;" > (< / span > > a b< span style = "color: #67b11d;" > )< / span >
result
< span style = "color: #67b11d;" > (< / span > iter-a < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > combiner < span style = "color: #4f97d7;" > (< / span > term a< span style = "color: #4f97d7;" > )< / span > result< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > iter-a a null-val< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > identity< / span > x< span style = "color: #bc6ec5;" > )< / span > x< span style = "color: #4f97d7;" > )< / span >
< 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;" > add1< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > + x < span style = "color: #a45bad;" > 1< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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-ai< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > accumulate-i sum-combiner < span style = "color: #a45bad;" > 0< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > prod-ai< / span > term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > accumulate-i < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > lambda< / span > < span style = "color: #67b11d;" > (< / span > t acc< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > * t acc< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 1< / span > term a next b< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > fakulteta-ai< / span > n< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > prod-ai identity < span style = "color: #a45bad;" > 2< / span > add1 n< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > excercise 1.33 filtered accumulate - combine only those term derived from< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > values in the range that satisfy a specified condition (predicate).< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > a) sum of squares of prime numbers - assuming prime? exists already< / span >
< 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;" > filtered-accumulate-r< / span > combiner null-val predicate term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > combiner 2 args - element and accumulation< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > predicate 1 arg - a condition when to apply combiner< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > term 1 arg - a function to compute the term< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > next 1 arg - compute a next step< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > > a b< span style = "color: #2d9574;" > )< / span >
null-val
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #67b11d;" > (< / span > predicate a< span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > combiner < span style = "color: #b1951d;" > (< / span > term a< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > filtered-accumulate-r combiner null-val predicate term < span style = "color: #4f97d7;" > (< / span > next a< span style = "color: #4f97d7;" > )< / span > next b< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > should I call combiner with null-val instead of (term a) or can I< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > directly call filtered-accumulate-r?< / span >
< span style = "color: #67b11d;" > (< / span > filtered-accumulate-r combiner null-val predicate term < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span > next b< span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > (filtered-accumulate-r sum-combiner 0 even? identity 1 add1 11)< / span >
< 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;" > filtered-accumulate-i< / span > combiner null-val predicate term a next b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > iter-fa< / span > a result< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #67b11d;" > (< / span > > a b< span style = "color: #67b11d;" > )< / span >
result
< span style = "color: #67b11d;" > (< / span > iter-fa < span style = "color: #b1951d;" > (< / span > next a< span style = "color: #b1951d;" > )< / span >
< span style = "color: #b1951d;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #4f97d7;" > (< / span > predicate a< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > combiner < span style = "color: #bc6ec5;" > (< / span > term a< span style = "color: #bc6ec5;" > )< / span > result< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > combiner null-val result< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #b1951d;" > )< / span >
< span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > iter-fa a null-val< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
2024-05-29 21:54:05 +02:00
< / pre >
2024-05-16 22:33:30 +02:00
< / div >
< / div >
2024-05-29 21:54:05 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orga3d1bae" class = "outline-3" >
< h3 id = "orga3d1bae" > < span class = "section-number-3" > 1.15.< / span > 1.3.2 Sestavljanje procedur z < code > Lambda< / code > < / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-15" >
2024-05-29 21:54:05 +02:00
< p >
Splosna forma < code > let< / code > izraza
< / p >
2024-05-16 22:33:30 +02:00
2024-08-21 21:38:05 +02:00
< pre class = "example" id = "orgf17c69c" >
2024-05-29 21:54:05 +02:00
(let ((< var1> < exp1> )
(< var2> < exp2> )
...
(< varn> < expn> ))
< body> )
< / pre >
< p >
To je okrajsava za
< / p >
2024-08-21 21:38:05 +02:00
< pre class = "example" id = "orge439e1d" >
2024-05-29 21:54:05 +02:00
((lambda (< var1> ... < varn> )
< body> )
< exp1>
...
< exp2>
)
< / pre >
< / div >
2024-05-16 22:33:30 +02:00
< / div >
2024-05-29 21:54:05 +02:00
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org7ddef27" class = "outline-3" >
< h3 id = "org7ddef27" > < span class = "section-number-3" > 1.16.< / span > 1.3.3 Procedure kot splosne metode< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-16" >
2024-05-29 21:54:05 +02:00
< p >
Ce pogledamo proceduro za integral, vidimo mocnejse abstrakcije: procedure, ki
izrazajo splosne racunske metode, neodvisne od posameznih vkljucenih funkcij.
< / p >
< / div >
2024-05-16 22:33:30 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org6e12126" class = "outline-3" >
< h3 id = "org6e12126" > < span class = "section-number-3" > 1.17.< / span > 1.3.4 Procedure kot vrnjene vrednosti< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-1-17" >
2024-05-29 21:54:05 +02:00
< p >
V splošnem programski jeziki omejujo, kateri komputacijski elemente lahko (koda)
spreminja. Elementi z najmanj omejitvami imajo < i > prvorazredni< / i > status. Pravice in
privilegiji prvorazrednih elementov so:
< / p >
< ul class = "org-ul" >
< li > lahko so poimenovani s spremenljivkami< / li >
< li > lahko so podani kot argumenti procedur< / li >
< li > lahko so vrnjeni kot rezultati procedur< / li >
< li > lahko so vključeni v podatkovne strukture< / li >
< / ul >
< p >
V Lispu imajo, za razliko od drugih programskih jezikov, procedure prvorazredni
status. To predstavlja težave za implementacijo, ampak nudi višjo ekspresivno
moč programskega jezika. Najvišja cena pri implementaciji procedur s
prvorazrednim statusom je, da je potrebno rezervirati prostor za procedurine
proste spremenljivke tudi, ko se procedura ne izvaja. V scheme-u so te
spremenljivke shranjene v procedurino okolje (poglavje 4.1).
< / p >
< / div >
< / div >
2024-05-16 22:33:30 +02:00
< / div >
2024-06-10 01:04:10 +02:00
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orge2a3918" class = "outline-2" >
< h2 id = "orge2a3918" > < span class = "section-number-2" > 2.< / span > Grajenje absrakcij s podatki< / h2 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-2" id = "text-2" >
< p >
Poglavje bo govorilo o kompleksnih podatkih. Poglavje 1 govori o grajenju
abstrakcij z zdruzevanjem procedur, ki tvorijo sestavljene procedure (compound).
V poglavju 2 pa bo fokus na grajenju abstrakcij z zdruzevanjem podatkovnih
objektov v sestavljene podatke (compound).
< / p >
< p >
Z zdruzenimi podatkovnimi objekti lahko procedure delajo nad njimi ne da bi bile
odvisne od njihove natancne strukture.
< / p >
< p >
Podobno kot pri sestavljenih procedurah gre tudi pri sestavljenih podatkovnih
objektih za nacin spoprijemanja s kompleksnostjo - podatkovne abstrakcije
omogocijo postavitev primernih abstrakcijskih pregrad med razlicnimi deli
programa.
< / p >
< p >
Napoved, kaj se bo pregledalo v 2. poglavju (bi bilo smiselno povzet).
< / p >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org4ed7803" class = "outline-3" >
< h3 id = "org4ed7803" > < span class = "section-number-3" > 2.1.< / span > Uvod v podatkovne abstrakcije< / h3 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-3" id = "text-2-1" >
< p >
Podatkovna abstrakcija je metodologija, ki nam omogoci, da locimo kako so
sestavljeni podatki uporabljeni od detajlov o tem, kako so izgrejeni iz
primitivnih podatkovnih objektov. (To je analogno grajenju produceur, ki imajo
vgrajene druge procedue iz poglavja 1.1.8)
< / p >
< p >
Skratka programe hocemo graditi tako, da uporabljajo podatke na nacin, da nimajo
nobenih predpostavk o tem, kaksni naj so ti podatki (oziroma cim manj), ravno
dovolj za izvajanje potrebnih operacij. Hkrati so konkretne reprezentacije
podatkov definirane neodvisno od programov, ki podatke uporabljajo.
< / p >
< p >
Selektorji in konstruktorji.
< / p >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org3f47737" class = "outline-4" >
< h4 id = "org3f47737" > < span class = "section-number-4" > 2.1.1.< / span > Aritmeticne operacije z racionalnimi stevili< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-2-1-1" >
< 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;" > add-rat< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-rat < span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > * < span style = "color: #b1951d;" > (< / span > numer x< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > denom y< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > * < span style = "color: #b1951d;" > (< / span > numer y< span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > denom x< 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 > denom x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > sub-rat< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-rat < span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > numer x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom y< span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > numer y< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom x< span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > denom x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > mul-rat< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-rat < span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > numer x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > numer y< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > denom x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > div-rat< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-rat < span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > numer x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom y< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > denom x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > numer y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > equal-rat?< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > = < span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > numer x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom y< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > numer y< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > denom x< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > make-rat< / span > n d< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > cons n d< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > numer< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > car x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > denom< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > cdr x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > print-rat< / span > x< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > (< / span > numer x< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > "/"< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > (< / span > denom x< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > newline< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5; font-weight: bold;" > one-half< / span > < span style = "color: #bc6ec5;" > (< / span > make-rat < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5; font-weight: bold;" > one-third< / span > < span style = "color: #bc6ec5;" > (< / span > make-rat < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 3< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > excercise 2.1< / span >
< 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;" > make-rat-norm< / span > n d< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > < d < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > make-rat < span style = "color: #67b11d;" > (< / span > * n < span style = "color: #a45bad;" > -1< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > * d < span style = "color: #a45bad;" > -1< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > make-rat n d< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
2024-08-21 21:38:05 +02:00
< 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;" > make-rat-norm-gcd< / span > n d< 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 > g < span style = "color: #b1951d;" > (< / span > gcd n d< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > make-rat-norm < span style = "color: #67b11d;" > (< / span > / n g< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > / d g< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
2024-06-10 01:04:10 +02:00
< / pre >
< / div >
< p >
Sestavljena strkutura < code > par< / code > , ki je konstruirana s primitivno proceduro < code > cons< / code > . S
primitivnimi procedurami < code > car< / code > in < code > cdr< / code > lahko dobimo prvi in ostale elemente
para.
< / p >
< / div >
< ul class = "org-ul" >
2024-08-21 21:38:05 +02:00
< li > < a id = "org5f082db" > < / a > Predstavljanje racionalnih stevil< br / >
< div class = "outline-text-5" id = "text-org5f082db" >
2024-06-10 01:04:10 +02:00
< p >
< i > Glej zgornji codeblock.< / i >
< / p >
< / div >
< / li >
< / ul >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-orgfeee81c" class = "outline-4" >
< h4 id = "orgfeee81c" > < span class = "section-number-4" > 2.1.2.< / span > Pregrade abstrakcij< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-2-1-2" >
< p >
Splosna ideja podatkovnih abstrakcij je, da se identificira za vsak tip podatka
osnovni set opraracij, s katerimi bodo vse procedure, ki bodo manipulirale
podatke operirale, oziroma bodo iz njih sestavljene. Nato se uporabljamo samo te
operacije pri delu s podatki.
< / p >
< p >
Pregrade:
< / p >
< ul class = "org-ul" >
< li > programi, ki uporabljajo racionalna stevila< / li >
< li > racionalna stevila v problemskem polju
< ul class = "org-ul" >
< li > < code > add-rat< / code > , < code > sub-rat< / code > … < / li >
< / ul > < / li >
< li > racionalna stevila kot stevci in imenovalci
< ul class = "org-ul" >
2024-08-21 21:38:05 +02:00
< li > < code > make-rat< / code > , < code > numer< / code > , < code > denom< / code > < / li >
2024-06-10 01:04:10 +02:00
< / ul > < / li >
< li > racionalna stevila kot pari
< ul class = "org-ul" >
< li > < code > cons< / code > , < code > car< / code > , < code > cdr< / code > < / li >
< / ul > < / li >
< li > kakor so pac pari implementirani< / li >
< / ul >
< p >
Procedure na vsakem nivoju so vmesniki, ki definirajo abstrakcijski nivo in med
sabo povezujejo razlicne nivoje.
< / p >
< p >
Ena od prednosti razdelitve na nivoje je, da je programe lazje vzdrzevati in
spreminjati, ker lahko delas spremembe na posameznem nivoju, ki ne vplivajo
izven svojega nivoja.
< / p >
< p >
< i > vaja 2.2< / i >
< / p >
< div class = "org-src-container" >
< pre class = "src src-scheme" > < span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > crte v prostoru< / span >
< 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;" > make-segment< / span > startp endp< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > cons startp endp< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > make-line< / span > x1 y1 x2 y2< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-segment < span style = "color: #2d9574;" > (< / span > make-point x1 y1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > make-point x2 y2< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > start-segment< / span > segment< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > car segment< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > end-segment< / span > segment< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > cdr segment< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > make-point< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > cons x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > x-point< / span > p< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > car p< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > y-point< / span > p< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > cdr p< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > mid-point< / span > segment< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-point
< span style = "color: #2d9574;" > (< / span > / < span style = "color: #67b11d;" > (< / span > + < span style = "color: #b1951d;" > (< / span > x-point < span style = "color: #4f97d7;" > (< / span > start-segment segment< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > x-point < span style = "color: #4f97d7;" > (< / span > end-segment segment< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > / < span style = "color: #67b11d;" > (< / span > + < span style = "color: #b1951d;" > (< / span > y-point < span style = "color: #4f97d7;" > (< / span > start-segment segment< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > y-point < span style = "color: #4f97d7;" > (< / span > end-segment segment< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 2< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > print-point< / span > p< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > "("< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > (< / span > x-point p< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > ","< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > (< / span > y-point p< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > display < span style = "color: #2d9574;" > ")"< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > newline< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > vaja 2.3 :: segment je lahko tudi pravokotnik, ce nimamo rotacije in je crta< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > vedno diagonala. Delal bom brez rotacije, zato ker potem ni dovolj imeti< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > konstruktorja, ki je samo kons, ampak rabim 3 parametre, segment in rotacija< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > in potem nvm kako delat selektorje in pa se vse se mi zakomplicira in se mi< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > ne da, ker je nedelja zvecer.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > brez rotacije - 2a + 2b< / span >
< 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;" > perimeter< / span > rectangle< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > + < span style = "color: #2d9574;" > (< / span > * < span style = "color: #a45bad;" > 2< / span > < span style = "color: #67b11d;" > (< / span > side-a rectangle< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > * < span style = "color: #a45bad;" > 2< / span > < span style = "color: #67b11d;" > (< / span > side-b rectangle< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > area< / span > rectangle< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > * < span style = "color: #2d9574;" > (< / span > side-a rectangle< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > side-b rectangle< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > selektor (brez rotacije)< / span >
< 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;" > side-a< / span > rectangle< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > abs < span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > x-point < span style = "color: #b1951d;" > (< / span > start-segment rectangle< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > x-point < span style = "color: #b1951d;" > (< / span > end-segment rectangle< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > side-b< / span > rectangle< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > abs < span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > y-point < span style = "color: #b1951d;" > (< / span > start-segment rectangle< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > y-point < span style = "color: #b1951d;" > (< / span > end-segment rectangle< 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 >
2024-08-21 21:38:05 +02:00
< 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;" > make-rectangle< / span > point-a point-c< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-segment point-a point-c< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > sedaj vpeljemo drugo reprezentacijo pravokotnikov (nic vec s segmentom) ali< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > lahko obseg in ploscina se vedno delujeta? odvisna sta od side-a in side-b.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Ce to zemanjam, bosta obseg in ploscina se vedno delovali.< / span >
< 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;" > mk-rect< / span > point-a sirina visina< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > get-point-c< / span > point-a sirina visina< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > cons < span style = "color: #67b11d;" > (< / span > + < span style = "color: #b1951d;" > (< / span > x-point point-a< span style = "color: #b1951d;" > )< / span > sirina< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > + < span style = "color: #b1951d;" > (< / span > y-point point-a< span style = "color: #b1951d;" > )< / span > visina< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-rectangle point-a < span style = "color: #2d9574;" > (< / span > get-point-c point-a sirina visina< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
2024-06-10 01:04:10 +02:00
< / pre >
< / div >
< / div >
< / div >
2024-08-21 21:38:05 +02:00
< div id = "outline-container-org50ad531" class = "outline-4" >
< h4 id = "org50ad531" > < span class = "section-number-4" > 2.1.3.< / span > Kaj so podatki?< / h4 >
2024-06-10 01:04:10 +02:00
< div class = "outline-text-4" id = "text-2-1-3" >
< p >
Pri racionalnih stevilih imamo se en pogoj:
< / p >
< p >
< code > (/ (numer x) (denom x)) = n/d< / code >
< / p >
< p >
2024-08-21 21:38:05 +02:00
Selektorji, konstruktorji in pogoji tvorijo veljavno reprezentacijo.
2024-06-10 01:04:10 +02:00
< / p >
< p >
Vsaka trojica procedur, ki ustreza pogoju, da ce zdruzis dva objekta, in potem z
eno proceduro dobis iz zdruzenih prvi objekt in z drugo drugi objekt, je potem
trojica procedu za delanje s pari.
< / p >
< p >
Trojico procedur (cons, car, cdr) se da implementirati brez podatkov:
< / 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;" > cons-p< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > dispatch< / span > m< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #67b11d;" > (< / span > < span style = "color: #b1951d;" > (< / span > = m < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > )< / span > x< span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > < span style = "color: #b1951d;" > (< / span > = m < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > y< span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #b1951d;" > (< / span > error < span style = "color: #2d9574;" > "Argument not 0 or 1 -- CONS"< / span > m< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
dispatch< span style = "color: #4f97d7;" > )< / span >
< 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;" > car-p< / span > z< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > z < span style = "color: #a45bad;" > 0< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > cdr-p< / span > z< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > z < span style = "color: #a45bad;" > 1< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< / pre >
< / div >
< p >
Zdaj imamo procedure za delanje s pari, ki so definirane brez podatkov.
Obskurno, ampak v okviru definije delanja s pari. Na tem primeru vidimo, da
zmoznost manipuliranja procedur kot objektov avtomaticno omogoci moznost za
reprezentacijo sestavljenih podatkov. (Proceduralna reprezentacija podatkov bo
igrala osrednjo vlogo v nadaljevanju - temu se rece < i > message passing< / i > in bo
osnovno orodje v tretjem poglavju o problemih modeliranja in simulacije).
< / p >
2024-08-21 21:38:05 +02:00
< div class = "org-src-container" >
< pre class = "src src-scheme" > < span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.5< / span >
< 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;" > cons-2a3b< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > * < span style = "color: #2d9574;" > (< / span > expt < span style = "color: #a45bad;" > 2< / span > a< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > expt < span style = "color: #a45bad;" > 3< / span > b< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > car-2a3b< / span > x< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > = < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > (< / span > modulo x < span style = "color: #a45bad;" > 2< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > + < span style = "color: #a45bad;" > 1< / span > < span style = "color: #67b11d;" > (< / span > car-2a3b < span style = "color: #b1951d;" > (< / span > / x < span style = "color: #a45bad;" > 2< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 0< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > cdr-2a3b< / span > x< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > = < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > (< / span > modulo x < span style = "color: #a45bad;" > 3< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > + < span style = "color: #a45bad;" > 1< / span > < span style = "color: #67b11d;" > (< / span > cdr-2a3b < span style = "color: #b1951d;" > (< / span > / x < span style = "color: #a45bad;" > 3< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #a45bad;" > 0< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > cons-2a3b < span style = "color: #a45bad;" > 3< / span > < span style = "color: #a45bad;" > 5< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > car-2a3b < span style = "color: #bc6ec5;" > (< / span > cons-2a3b < span style = "color: #a45bad;" > 3< / span > < span style = "color: #a45bad;" > 5< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #4f97d7;" > (< / span > cdr-2a3b < span style = "color: #bc6ec5;" > (< / span > cons-2a3b < span style = "color: #a45bad;" > 3< / span > < span style = "color: #a45bad;" > 5< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.6 church numerals< / span >
< span style = "color: #4f97d7;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5; font-weight: bold;" > zero< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #2d9574;" > (< / span > x< span style = "color: #2d9574;" > )< / span > x< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > add-1< / span > n< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #2d9574;" > (< / span > f< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #67b11d;" > (< / span > x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > f < span style = "color: #b1951d;" > (< / span > < span style = "color: #4f97d7;" > (< / span > n f< span style = "color: #4f97d7;" > )< / span > x< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5; font-weight: bold;" > one< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #2d9574;" > (< / span > f< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #67b11d;" > (< / span > x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > f < span style = "color: #b1951d;" > (< / span > f x< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5; font-weight: bold;" > two< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #2d9574;" > (< / span > f< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > λ < / span > < span style = "color: #67b11d;" > (< / span > x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > f < span style = "color: #b1951d;" > (< / span > f < span style = "color: #4f97d7;" > (< / span > f x< span style = "color: #4f97d7;" > )< / span > < 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > pomoje je to narobe, en f prevec je. ampak, ko sva z gizmotom na papir< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > napisala je bilo kul.< / span >
< / pre >
< / div >
< / div >
< / div >
< div id = "outline-container-org8f92707" class = "outline-4" >
< h4 id = "org8f92707" > < span class = "section-number-4" > 2.1.4.< / span > razsirjena vaja: aritmetika z intervali< / h4 >
< div class = "outline-text-4" id = "text-2-1-4" >
< div class = "org-src-container" >
< pre class = "src src-scheme" > < span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > aritmetika z intervali< / span >
< 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;" > add-interval< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-interval < span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > lower-bound x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > lower-bound y< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > upper-bound x< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > upper-bound y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > mul-interval< / span > x y< 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 > p1 < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > p2 < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > p3 < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > p4 < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< 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 > make-interval < span style = "color: #67b11d;" > (< / span > min p1 p2 p3 p4< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > max p1 p2 p3 p4< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > @todo tukaj ne razumem, kako to, da ni p1 vedno najmanjsi in p4 vedno najvecji.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > https://en.wikipedia.org/wiki/Interval_arithmetic< / span >
< 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;" > div-interval< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > mul-interval x
< span style = "color: #2d9574;" > (< / span > make-interval < span style = "color: #67b11d;" > (< / span > / < span style = "color: #a45bad;" > 1.0< / span > < span style = "color: #b1951d;" > (< / span > upper-bound y< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > / < span style = "color: #a45bad;" > 1.0< / span > < span style = "color: #b1951d;" > (< / span > lower-bound y< 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.7< / span >
< 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;" > make-interval< / span > a b< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > cons a b< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > upper-bound< / span > i< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > cdr i< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > lower-bound< / span > i< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > car i< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.8< / span >
< 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;" > sub-interval< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-interval < span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > lower-bound a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > upper-bound b< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > upper-bound a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > lower-bound b< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > od spodnje meje odstejes zgornjo mejo drugega intervala< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.9< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > Pokazi, da je sirina intervala (polovica razdalje med zgornjo in spodnjo< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > mejo),oziroma, da je sirina vsote in razlike intervalov funkcija sirin< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > argumentov ter da sirina proudkta in deljenja ni funkcija sirine.< / span >
< 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;" > width< / span > a< span style = "color: #bc6ec5;" > )< / span > < span style = "color: #bc6ec5;" > (< / span > / < span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > upper-bound a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > lower-bound a< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 2.0< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > sirina vsote je enaka vsoti sirin, ce razpises je hitro jasno.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > sirina razlike je enaka vsoti sirin.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > pri mnozenju imamo funkcijo min in max in ubistvu se nikjer notri ne pojavi< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > sirina.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.10< / span >
< 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;" > safe-div-interval< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span > < span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > or< / span > < span style = "color: #67b11d;" > (< / span > = < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > (< / span > lower-bound y< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > = < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > (< / span > upper-bound y< span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > error < span style = "color: #2d9574;" > "Division by zero?"< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > div-interval x y< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.11< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > S preverjanjem predznakov v mejah intervalov lahko locis mnozenje intervalov< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > na 9 primermov, od katerih samo eden potrebuje vec kot 2 mnozenji. Razpisi< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > s to metodo.< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > verjetno bi rabil se neko preverjanje, da je nizja meja intervala res nizja.< / span >
< 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;" > mul-interval-signs< / span > x y< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > en cel pozit, drug cel negat< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > en cez nic, drug cel pozit< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > en cez nic, drug cel negat< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > upper-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< 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 > < span style = "color: #4f97d7; font-weight: bold;" > and< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > = < span style = "color: #4f97d7;" > (< / span > test-sign-interval y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > make-interval < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > upper-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #b1951d;" > (< / span > * < span style = "color: #4f97d7;" > (< / span > lower-bound x< span style = "color: #4f97d7;" > )< / span > < span style = "color: #4f97d7;" > (< / span > lower-bound y< span style = "color: #4f97d7;" > )< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > oba cez nic, je treba sprobat< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #67b11d;" > (< / span > mul-interval x y< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > returns -1 if lower and upper bound are below 0< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > return 0 if lower bound is below 0 and upper bound is above< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > return 1 if both bounds are above 0< / span >
< 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;" > test-sign-interval< / span > x< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > cond< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > > = < span style = "color: #b1951d;" > (< / span > lower-bound x< span style = "color: #b1951d;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #67b11d;" > (< / span > < < span style = "color: #b1951d;" > (< / span > upper-bound x< span style = "color: #b1951d;" > )< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #a45bad;" > -1< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > else< / span > < span style = "color: #a45bad;" > 0< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > test mul intervals - definiram 3 intervale in jih mnozim same s sabo in< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > drugega z drugim.< / span >
< 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;" > test-mul-int< / span > < 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 > i1 < span style = "color: #b1951d;" > (< / span > make-interval < span style = "color: #a45bad;" > 2< / span > < span style = "color: #a45bad;" > 3< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > i2 < span style = "color: #b1951d;" > (< / span > make-interval < span style = "color: #a45bad;" > -5< / span > < span style = "color: #a45bad;" > 7< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #67b11d;" > (< / span > i3 < span style = "color: #b1951d;" > (< / span > make-interval < span style = "color: #a45bad;" > -13< / span > < span style = "color: #a45bad;" > -11< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span >
< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )(< / span > display i1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i1 i1< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i1 i1< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i2< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )(< / span > display i2< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i2 i2< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i2 i2< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i3< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )(< / span > display i3< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i3 i3< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i3 i3< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display i2< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i1 i2< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i1 i2< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display i3< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i1 i3< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i1 i3< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i2< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display i3< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i2 i3< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i2 i3< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i3< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display i2< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i3 i2< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i3 i2< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i3< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display i1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i3 i1< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i3 i1< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > display i2< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " * "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display i1< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " mul: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval i2 i1< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #2d9574;" > " sig: "< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > display < span style = "color: #67b11d;" > (< / span > mul-interval-signs i2 i1< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > newline< span style = "color: #2d9574;" > )< / span >
< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< 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;" > make-center-width< / span > c w< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-interval < span style = "color: #2d9574;" > (< / span > - c w< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > + c w< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > center< / span > i< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > / < span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > lower-bound i< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > upper-bound i< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 2.0< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > width< / span > i< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > / < span style = "color: #2d9574;" > (< / span > - < span style = "color: #67b11d;" > (< / span > upper-bound i< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > lower-bound i< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #a45bad;" > 2.0< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > nalog 2.12< / span >
< 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;" > make-center-percent< / span > c p< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > percentage is between 0 and 1< / span >
< span style = "color: #bc6ec5;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > if< / span >
< span style = "color: #2d9574;" > (< / span > < span style = "color: #4f97d7; font-weight: bold;" > or< / span > < span style = "color: #67b11d;" > (< / span > < p < span style = "color: #a45bad;" > 0.0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > > p < span style = "color: #a45bad;" > 1.0< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > error < span style = "color: #2d9574;" > "Percentage should be a decimal number between 0 and 1"< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > make-center-width c < span style = "color: #67b11d;" > (< / span > * c p< 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 > < span style = "color: #4f97d7; font-weight: bold;" > define< / span > < span style = "color: #bc6ec5;" > (< / span > < span style = "color: #bc6ec5; font-weight: bold;" > percent< / span > i< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > / < span style = "color: #2d9574;" > (< / span > width i< span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > center i< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.13< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > za majhne odstotke je preprosta forumalu za priblizek produkta.< / span >
< 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;" > interval-mul-pribl< / span > a b< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > make-center-percent < span style = "color: #2d9574;" > (< / span > * < span style = "color: #67b11d;" > (< / span > center a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > center b< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #2d9574;" > (< / span > + < span style = "color: #67b11d;" > (< / span > percent a< span style = "color: #67b11d;" > )< / span > < span style = "color: #67b11d;" > (< / span > percent b< span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #4f97d7;" > )< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > nvm ce je to to, ampak za mnozejnje (make-center-percent 1000 0.01) in (mcp< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > 2000 0.01) dobim za produkt po direktni formuli percent produkta 0.019998, po< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > moji formuli za priblizek pa 0.02, kar je dost podobno.< / span >
< 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;" > par1< / span > r1 r2< span style = "color: #bc6ec5;" > )< / span >
< span style = "color: #bc6ec5;" > (< / span > div-interval < span style = "color: #2d9574;" > (< / span > mul-interval r1 r2< span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > add-interval r1 r2< span style = "color: #2d9574;" > )< / span > < span style = "color: #bc6ec5;" > )< / span > < span style = "color: #4f97d7;" > )< / span >
< 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;" > par2< / span > r1 r2< 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 > one < span style = "color: #b1951d;" > (< / span > make-interval < span style = "color: #a45bad;" > 1< / span > < span style = "color: #a45bad;" > 1< / span > < span style = "color: #b1951d;" > )< / span > < span style = "color: #67b11d;" > )< / span > < span style = "color: #2d9574;" > )< / span >
< span style = "color: #2d9574;" > (< / span > div-interval one
< span style = "color: #67b11d;" > (< / span > add-interval < span style = "color: #b1951d;" > (< / span > div-interval one r1< span style = "color: #b1951d;" > )< / span >
< span style = "color: #b1951d;" > (< / span > div-interval one r2< 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: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.14< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > hja dobimo drugacne rezultate, nvm zakaj...< / span >
< span style = "color: #2aa1ae; background-color: #292e34;" > ;; < / span > < span style = "color: #2aa1ae; background-color: #292e34;" > naloga 2.15< / span >
< / pre >
< / div >
< / div >
< / div >
< / div >
< div id = "outline-container-org324d412" class = "outline-3" >
< h3 id = "org324d412" > < span class = "section-number-3" > 2.2.< / span > Hierarhični podatki in lastnosti zaprtosti< / h3 >
< div class = "outline-text-3" id = "text-2-2" >
< div class = "org-center" >
< p >
Closure Property =>
< a href = "https://dis-slovarcek.ijs.si/list_searched" > https://dis-slovarcek.ijs.si/list_searched< / a >
< / p >
< / div >
< p >
Pare sestavljamo s < code > cons< / code > .
< / p >
< p >
Sposobnost ustvarjanja/sestavljanja parov, katerih elementi so pari je bistvo
strukture podatkovnih seznamov kot orodja za reprezentacijo. Temu recemo
lastnosti zaprtosti. Na splosno, operacija za zdruzevanje podatkov zadosca
< b > lastnosti zaprtosti< / b > , ce so lahko rezultati zdruzevanja podatkov tudi sami
zdruzeni z istimi operacijami.
< / p >
< p >
< i > Treba je pazit, ker closure tukaj pride iz abstraktne algebre. Lisp skupnost pa< / i >
< i > s closure opisuje tudi nepovezan koncept - implementacijsko tehniko za procedure< / i >
< i > s prostimi spremenljivkami. V sicp closure nima tega pomena.< / i >
< / p >
< p >
Zaprtost je kljuc do sredstev kombinacij, ker omogoca ustvarjanje hierarhicnih
struktur - struktur, ki so sestavljene iz struktur.
< / p >
< / div >
< div id = "outline-container-org2fa71cc" class = "outline-4" >
< h4 id = "org2fa71cc" > < span class = "section-number-4" > 2.2.1.< / span > Reprezentacija sekvenc< / h4 >
< div class = "outline-text-4" id = "text-2-2-1" >
< p >
< code > list< / code > funkcija je ekvivalentna konsanju argumentov na < code > cons< / code > .
< / p >
< / div >
< ol class = "org-ol" >
< li > < a id = "orgce017ec" > < / a > operacije s seznami< br / > < / li >
< / ol >
2024-06-10 01:04:10 +02:00
< / div >
< / div >
< / div >
2024-04-30 19:33:52 +02:00
< / div >
2024-08-21 21:38:05 +02:00
< div id = "postamble" class = "status" >
< p class = "author" > Author: Lio Novelli< / p >
< p class = "date" > Created: 2024-08-21 Wed 21:37< / p >
< p class = "validation" > < a href = "https://validator.w3.org/check?uri=referer" > Validate< / a > < / p >
2024-04-30 19:33:52 +02:00
< / div >
< / body >
< / html >