Posodobitev

main
Jurij Podgoršek 2024-05-17 12:44:20 +02:00
parent 4c1b758a56
commit 41eebcd583
3 changed files with 610 additions and 21 deletions

View File

@ -3,10 +3,11 @@
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head> <head>
<!-- 2024-05-16 Thu 01:05 --> <!-- 2024-05-17 pet 12:43 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Kompotov programerski bralni krožek #1: SICP</title> <title>Kompotov programerski bralni krožek #1: SICP</title>
<meta name="author" content="Yuri" />
<meta name="generator" content="Org Mode" /> <meta name="generator" content="Org Mode" />
<style> <style>
#content { max-width: 60em; margin: auto; } #content { max-width: 60em; margin: auto; }
@ -197,7 +198,7 @@
<body> <body>
<div id="content" class="content"> <div id="content" class="content">
<h1 class="title">Kompotov programerski bralni krožek #1: SICP</h1> <h1 class="title">Kompotov programerski bralni krožek #1: SICP</h1>
<div class="footer" id="orgfbb157d"> <div class="footer" id="orgc1028a9">
<p> <p>
Izvorna koda se nahaja na <a href="https://git.kompot.si/programerski-bralni-krozek/sicp">git.kompot.si</a>. Izvorna koda se nahaja na <a href="https://git.kompot.si/programerski-bralni-krozek/sicp">git.kompot.si</a>.
</p> </p>
@ -213,18 +214,53 @@ Za bralni krožek se dogovarjamo prek (javne) mailing liste, na katero se lahko
</p> </p>
<div id="org26b3051" class="figure"> <div id="org1569423" class="figure">
<p><img src="./tb.jpg" alt="tb.jpg" /> <p><img src="./tb.jpg" alt="tb.jpg" />
</p> </p>
</div> </div>
<div id="outline-container-org5195aa4" class="outline-2"> <div id="outline-container-org14c9c4c" class="outline-2">
<h2 id="org5195aa4">Srečanja</h2> <h2 id="org14c9c4c">Srečanja</h2>
<div class="outline-text-2" id="text-org5195aa4"> <div class="outline-text-2" id="text-org14c9c4c">
</div> </div>
<div id="outline-container-org8d56f70" class="outline-3"> <div id="outline-container-org19a2e8a" class="outline-3">
<h3 id="org8d56f70">#2: torek, 30. 4. 2024 18.45 v CTK</h3> <h3 id="org19a2e8a">#4: sreda, 29. 5. 2024 18.45 v CTK</h3>
<div class="outline-text-3" id="text-org8d56f70"> <div class="outline-text-3" id="text-org19a2e8a">
<p>
Dogodek je <a href="https://dogodki.kompot.si/events/0f3df86f-abc0-4725-bb4c-3587262a672c">tukaj</a>.
Preglejujemo naloge iz prvega poglavja.
</p>
</div>
</div>
<div id="outline-container-org80c7d8b" class="outline-3">
<h3 id="org80c7d8b">#3: četrtek, 16. 5. 2024 18.45 v CTK</h3>
<div class="outline-text-3" id="text-org80c7d8b">
<p>
Kot ponavadi je dogodek na našem <a href="https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d">mobilizonu</a>.
</p>
<p>
Prebrali smo poglavje 1.3, razvijanje abstrakcij s postopki višjega reda.
Ker vsebuje poglavje veliko vaj, za katere nismo našli časa, smo se odločili do naslednjič nadoknaditi zamujeno.
Na srečanju smo skupaj reševali vajo 1.29.
</p>
</div>
<div id="outline-container-org2e21a8d" class="outline-4">
<h4 id="org2e21a8d">zapiski</h4>
<div class="outline-text-4" id="text-org2e21a8d">
<ul class="org-ul">
<li><a href="zapiski/sicp-lio.html#MissingReference">lio</a></li>
<li><a href="./zapiski/3_g1smo.scm">g1smo</a></li>
</ul>
</div>
</div>
</div>
<div id="outline-container-org6a834f1" class="outline-3">
<h3 id="org6a834f1">#2: torek, 30. 4. 2024 18.45 v CTK</h3>
<div class="outline-text-3" id="text-org6a834f1">
<p> <p>
Dogodek je <a href="https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d">tukaj</a>. Dogodek je <a href="https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d">tukaj</a>.
</p> </p>
@ -234,21 +270,21 @@ Nadaljujemo z branjem poglavja 1.2, Procedures and the processes they generate.
</p> </p>
</div> </div>
<div id="outline-container-orgc07a296" class="outline-4"> <div id="outline-container-orgb5dace1" class="outline-4">
<h4 id="orgc07a296">zapiski</h4> <h4 id="orgb5dace1">zapiski</h4>
<div class="outline-text-4" id="text-orgc07a296"> <div class="outline-text-4" id="text-orgb5dace1">
<ul class="org-ul"> <ul class="org-ul">
<li><a href="zapiski/sicp_1_2_tina.md">tina</a> (<a href="zapiski/sicp_1_2_tina.scm">vaje</a>, <a href="zapiski/sicp_sec_1_2.scm">druga varjanta</a>)</li> <li><a href="zapiski/sicp_1_2_tina.md">tina</a> (<a href="zapiski/sicp_1_2_tina.scm">vaje</a>, <a href="zapiski/sicp_sec_1_2.scm">druga varjanta</a>)</li>
<li><a href="zapiski/sicp-lio.html">lio</a></li> <li><a href="zapiski/sicp-lio.html#MissingReference">lio</a></li>
<li><a href="zapiski/2_g1smo.html">g1smo</a></li> <li><a href="zapiski/2_g1smo.html">g1smo</a></li>
</ul> </ul>
</div> </div>
</div> </div>
</div> </div>
<div id="outline-container-org0250b6a" class="outline-3"> <div id="outline-container-org34051e2" class="outline-3">
<h3 id="org0250b6a">#1: sreda, 17. 4. 2024 18.45 v CTK</h3> <h3 id="org34051e2">#1: sreda, 17. 4. 2024 18.45 v CTK</h3>
<div class="outline-text-3" id="text-org0250b6a"> <div class="outline-text-3" id="text-org34051e2">
<p> <p>
Beremo uvod in do poglavja 1.2, približno 30 strani. Beremo uvod in do poglavja 1.2, približno 30 strani.
</p> </p>
@ -258,9 +294,9 @@ Link do <a href="https://dogodki.kompot.si/events/76672075-1c6f-48f1-bc37-05dde9
</p> </p>
</div> </div>
<div id="outline-container-orgcc0690f" class="outline-4"> <div id="outline-container-orgaf97219" class="outline-4">
<h4 id="orgcc0690f">zapiski</h4> <h4 id="orgaf97219">zapiski</h4>
<div class="outline-text-4" id="text-orgcc0690f"> <div class="outline-text-4" id="text-orgaf97219">
<ul class="org-ul"> <ul class="org-ul">
<li><a href="zapiski/1_g1smo.html">g1smo</a></li> <li><a href="zapiski/1_g1smo.html">g1smo</a></li>
<li><a href="zapiski/sicp-lio.html">lio</a></li> <li><a href="zapiski/sicp-lio.html">lio</a></li>
@ -271,7 +307,8 @@ Link do <a href="https://dogodki.kompot.si/events/76672075-1c6f-48f1-bc37-05dde9
</div> </div>
</div> </div>
<div id="postamble" class="status"> <div id="postamble" class="status">
<p class="date">Created: 2024-05-16 Thu 01:05</p> <p class="author">Author: Yuri</p>
<p class="date">Created: 2024-05-17 pet 12:43</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p> <p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div> </div>
</body> </body>

View File

@ -14,6 +14,21 @@ Za bralni krožek se dogovarjamo prek (javne) mailing liste, na katero se lahko
[[file:./tb.jpg]] [[file:./tb.jpg]]
* Srečanja * Srečanja
** #4: sreda, 29. 5. 2024 18.45 v CTK
Dogodek je [[https://dogodki.kompot.si/events/0f3df86f-abc0-4725-bb4c-3587262a672c][tukaj]].
Preglejujemo naloge iz prvega poglavja.
** #3: četrtek, 16. 5. 2024 18.45 v CTK
Kot ponavadi je dogodek na našem [[https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d][mobilizonu]].
Prebrali smo poglavje 1.3, razvijanje abstrakcij s postopki višjega reda.
Ker vsebuje poglavje veliko vaj, za katere nismo našli časa, smo se odločili do naslednjič nadoknaditi zamujeno.
Na srečanju smo skupaj reševali vajo 1.29.
*** zapiski
- [[file+emacs:zapiski/sicp-lio.org::1.3 Sestavljanje abstrakcij s procedurami visjega reda][lio]]
- [[file:./zapiski/3_g1smo.scm][g1smo]]
** #2: torek, 30. 4. 2024 18.45 v CTK ** #2: torek, 30. 4. 2024 18.45 v CTK
Dogodek je [[https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d][tukaj]]. Dogodek je [[https://dogodki.kompot.si/events/8435c26d-4dbd-4e28-94c2-a237c837865d][tukaj]].
@ -21,7 +36,7 @@ Nadaljujemo z branjem poglavja 1.2, Procedures and the processes they generate.
*** zapiski *** zapiski
- [[file:zapiski/sicp_1_2_tina.md][tina]] ([[file:zapiski/sicp_1_2_tina.scm][vaje]], [[file:zapiski/sicp_sec_1_2.scm][druga varjanta]]) - [[file:zapiski/sicp_1_2_tina.md][tina]] ([[file:zapiski/sicp_1_2_tina.scm][vaje]], [[file:zapiski/sicp_sec_1_2.scm][druga varjanta]])
- [[file+emacs:zapiski/sicp-lio.org][lio]] - [[file+emacs:zapiski/sicp-lio.org::1.2.2 Drevesna rekurzija][lio]]
- [[file:zapiski/2_g1smo.org][g1smo]] - [[file:zapiski/2_g1smo.org][g1smo]]
** #1: sreda, 17. 4. 2024 18.45 v CTK ** #1: sreda, 17. 4. 2024 18.45 v CTK

View File

@ -0,0 +1,537 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<!-- 2024-04-30 tor 19:39 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
<meta name="author" content="Yuri" />
<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">
<p>
#lang scheme
</p>
<p>
;; 1.9
</p>
<p>
;; 1. primer: rekurziven
;; (+ 4 5) = inc((inc(inc(inc(5)))) = inc((inc(inc(6))) = inc((inc(7)) = inc(8) = 9
;; 2. primer: iterativen
;; (+ 4 5):
;; (+ 3 6)
;; (+ 2 7)
;; (+ 1 8)
;; (+ 0 9)
;; 9
</p>
<p>
;; 1.10
;; Ackermannova funkcija
;; <a href="https://en.wikipedia.org/wiki/Ackermann_function">https://en.wikipedia.org/wiki/Ackermann_function</a> - tukaj malo drugacna definicija, mislim, da se indeksiranje premakne za 3
</p>
<p>
( define (A x y)
( cond ((= y 0 ) 0 )
(( = x 0 ) ( * 2 y))
((= y 1 ) 2 )
( else (A ( - x 1 )
( A x ( - y 1 ) ) ) ) ) )
</p>
<p>
(A 1 10 )
(A 2 4)
(A 3 3)
</p>
<p>
;; (f n) = 2*n
;; (g n) = 2<sup>n</sup>
;; (h n) =
</p>
<p>
;;;; iz knjige
;;;;
(define (fib n)
( cond (( = n 0 ) 0)
(( = n 1) 1 )
( else ( + ( fib ( - n 1 ) )
( fib ( - n 2 ) ) ) ) ) )
</p>
<p>
(fib 10)
;;;;
;;;;
</p>
<p>
;; 1.11
</p>
<p>
;; rekurzivno
(define (f-rec n)
( cond (( &lt; n 3 ) n)
( else ( + (f-rec ( - n 1 )) (* 2 (f-rec (- n 2))) (* 3 (f-rec (- n 3)))))))
</p>
<p>
(f-rec 6)
</p>
<p>
;;;; iz knjige
;;;;
( define (fib2 n)
( fib-iter 1 0 n) )
</p>
<p>
( define ( fib-iter a b count )
( if (= count 0 )
b
( fib-iter (+ a b) a ( - count 1 ) ) ) )
</p>
<p>
(fib2 10)
;;;;
;;;;
</p>
<p>
;; iterativno
( define (f2 n)
( f-iter n (if (&lt; n 2) n 2)) )
</p>
<p>
( define ( f-iter max-count sum)
( if (&lt; max-count 3 )
max-count
(+ (f-iter (- max-count 1) sum) (* 2 (f-iter (- max-count 2) sum )) (* 3 (f-iter (- max-count 3) sum )))))
</p>
<p>
(f2 6)
</p>
<p>
;; 1.12
(define (pascal r c)
(if (or (= r 0) (= c 1) (= c r))
1
(+ (pascal (- r 1) c) (pascal (- r 1) (- c 1)))))
</p>
<p>
(pascal 5 3)
</p>
<p>
;; 1.13 na papirju
</p>
<p>
;; 1.14 na papirju
</p>
<p>
;;;; iz knjige
;;;;
( define ( count-change amount )
( cc amount 5 ) )
</p>
<p>
( define ( cc amount kinds-of-coins )
( cond (( = amount 0) 1 )
(( or (&lt; amount 0 ) ( = kinds-of-coins 0 ) ) 0 )
( else (+ ( cc amount
( - kinds-of-coins 1 ) )
( cc ( - amount
( first-denomination kinds-of-coins ) )
kinds-of-coins ) ) ) ) )
(define ( first-denomination kinds-of-coins)
( cond (( = kinds-of-coins 1 ) 1)
(( = kinds-of-coins 2 ) 5)
(( = kinds-of-coins 3) 10 )
(( = kinds-of-coins 4) 25 )
(( = kinds-of-coins 5 ) 50) ) )
</p>
<p>
( count-change 11)
;;;;
;;;;
</p>
<p>
;;;; iz knjige
;;;;
(define (square x) (* x x))
</p>
<p>
( define ( even? n)
(= (remainder n 2 ) 0 ) )
</p>
<p>
( define ( fast-expt b n)
( cond ( (= n 0 ) 1 )
( ( even? n ) ( square ( fast-expt b ( / n 2 ) ) ) )
( else ( * b ( fast-expt b ( - n 1 ) ) ) ) ) )
</p>
<p>
(fast-expt 2 5)
;;;;
;;;;
</p>
<p>
;; 1.15
;; a) 5
;; b) O(log n) (?)
</p>
<p>
;; 1.16
( define ( fast-exp-iter n b a )
( if (= n 0 )
a
(if (even? n) (fast-exp-iter ( / n 2 ) (square b) a ) ( * b ( fast-exp-iter ( - n 1 ) (* a b) a ) ) ) ) )
</p>
<p>
(fast-exp-iter 10 2 1 )
</p>
<p>
;; 1.17
</p>
<p>
;;;; iz knjige
;;;;
(define (mult a b)
(if (= b 0)
0
(+ a (mult a (- b 1 ) ) ) ) )
</p>
<p>
(mult 3 4)
;;;;
;;;;
</p>
<p>
;; naloga
(define (double x) (+ x x))
(define (halve x) (/ x 2)) ;; a bi to moralo biti kako drugace; zakaj uporabljam deljenje pri implementaciji mnozenja s sestevanjem
</p>
<p>
( define ( fast-mult a b)
( cond ( (= b 0 ) 0 )
( ( even? b ) ( double ( fast-mult a (halve b) ) ) )
( else ( + a ( fast-mult a ( - b 1 ) ) ) ) ) )
</p>
<p>
(fast-mult 8 7)
</p>
<p>
;; 1.18
</p>
<p>
( define ( fast-mult-iter b a c)
( if (= b 0 )
0
(if (even? b) (fast-mult-iter (halve b) (double a) c ) ( + a ( fast-mult-iter ( - b 1 ) a c ) ) ) ) )
</p>
<p>
(fast-mult-iter 18 10 0 )
</p>
<p>
;; 1.21
</p>
<p>
;;;; iz knjige
;;;;
( define ( smallest-divisor n)
( find-divisor n 2 ) )
( define (find-divisor n test-divisor)
( cond (( &gt; ( square test-divisor) n) n)
(( divides? test-divisor n) test-divisor)
(else ( find-divisor n (+ test-divisor 1 ) ) ) ) )
( define (divides? a b )
(= (remainder b a) 0 ) )
</p>
<p>
(smallest-divisor 19999)
</p>
<p>
( define (prime? n)
(= n ( smallest-divisor n) ) )
;;;;
;;;;
</p>
<p>
;; 1.22
</p>
<p>
(define (runtime) (current-milliseconds)) ;; brez tega error: runtime: unbound identifier in: runtime
</p>
<p>
;;;; iz knjige
;;;;
(define (timed-prime-test n)
(newline)
(display n)
(start-prime-test n (runtime)))
(define (start-prime-test n start-time)
(if (prime? n)
(report-prime (- (runtime) start-time)) -1))
(define (report-prime elapsed-time)
(display "<b>*</b>" )
(display elapsed-time))
;;;;
;;;;
</p>
<p>
(timed-prime-test 87178291199) ;; 35742549198872617291353508656626642567
</p>
<p>
;; <a href="https://en.wikipedia.org/wiki/List_of_prime_numbers">https://en.wikipedia.org/wiki/List_of_prime_numbers</a>
</p>
<p>
;; 1.26
;; ker se s klicanjem (/ exp 2) v navadnem mnozenju parameter exp ne razpolovi v naslednjem koraku ?</p>
</div>
<div id="postamble" class="status">
<p class="author">Author: Yuri</p>
<p class="date">Created: 2024-04-30 tor 19:39</p>
<p class="validation"><a href="https://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
</html>