Warning: Declaration of action_plugin_subjectindex_indexer::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/subjectindex/action/indexer.php on line 15

Warning: Declaration of action_plugin_mathjax_enable::register(Doku_Event_Handler &$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/mathjax/action/enable.php on line 62

Warning: Declaration of action_plugin_googleanalytics::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/googleanalytics/action.php on line 40

Warning: Declaration of action_plugin_folded::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/folded/action.php on line 40

Warning: Declaration of action_plugin_hidden::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/hidden/action.php on line 28

Warning: Declaration of action_plugin_include::register(&$controller) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/include/action.php on line 354

Warning: Declaration of action_plugin_tag::register(&$contr) should be compatible with DokuWiki_Action_Plugin::register(Doku_Event_Handler $controller) in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/tag/action.php on line 175

Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/subjectindex/action/indexer.php:15) in /data/web/virtuals/28604/virtual/www/subdom/bo/inc/auth.php on line 532

Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /data/web/virtuals/28604/virtual/www/subdom/bo/inc/auth.php on line 818

Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /data/web/virtuals/28604/virtual/www/subdom/bo/inc/parser/handler.php on line 1376

Warning: Declaration of SI_EntryDefault::match($text) should be compatible with SI_Entry::match() in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/subjectindex/plugins/EntryDefault.php on line 68

Warning: Declaration of SI_EntryTag::match($text) should be compatible with SI_Entry::match() in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/subjectindex/plugins/EntryTag.php on line 42

Warning: Declaration of SI_EntryVerse::match($text) should be compatible with SI_Entry::match() in /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/subjectindex/plugins/EntryVerse.php on line 1280

Warning: preg_match(): Compilation failed: invalid range in character class at offset 4360 in /data/web/virtuals/28604/virtual/www/subdom/bo/inc/parser/lexer.php on line 118
A PCRE internal error occured. This might be caused by a faulty plugin

Warning: Cannot modify header information - headers already sent by (output started at /data/web/virtuals/28604/virtual/www/subdom/bo/lib/plugins/subjectindex/action/indexer.php:15) in /data/web/virtuals/28604/virtual/www/subdom/bo/inc/actions.php on line 215
YPP1:C7R.scm [Bo.bule]

======C7R.scm====== <code shell>#!/usr/bin/env racket #lang racket/base</code> zadání (slepá mapa) viz [[C7.scm]], 2014-jan-17 (honz4) ======1. abs-min====== V [[PAPR1:L7#s7_3|sekci 7.3]] jsme rozšířili proceduru min2 na proceduru libovolného počtu argumentů. Stejným způsobem rozšiřte proceduru na výběr čísla s extrémní absolutní hodnotou abs-min. <hidden potrebujeme abs-min a menší-rovno s +infty> <code scheme> (define +oo '+oo) </code> y=oo || (x!=oo && x <= y) ;Ceckovy zapis <= s nekonecnem <code scheme> (define <=oo (lambda (x y) (or (equal? y +oo) (and (not (equal? x +oo)) (<= x y))))) (map <=oo '(1 2 3 1 +oo +oo) '(2 1 3 +oo 1 +oo)) ;zabudujeme +oo i do abs? (define (abs+oo x) (if (equal? x +oo) x (abs x))) (define abs-min2 ;abs zabudovano v <=oo ??? (lambda (x y) (if (<=oo (abs+oo x) (abs+oo y)) x y))) ;vracime 'originalni' x y (define abs-min2__ (lambda (x y) (if (<=oo x y) x y))) (abs-min2 -10 8) ;=> 8 (define abs-min (lambda numbers (foldr abs-min2 +oo numbers))) (abs-min -10 -8 2 5 6) ;=> 2 </code> </hidden> ======2. nondecreasing====== Napište predikát, který pro posloupnost zjistí, zda je neklesající. Posloupnost bude reprezentovaná seznamem, jehož prvky jsou čísla. Viz příklady aplikace: <code scheme> (nondecreasing? '()) ;⇒ #t (nondecreasing? '(1 2 3 4)) ;⇒ #t (nondecreasing? '(1 2 4 3)) ;⇒ #f (nondecreasing? '(1 4 2 3)) ;⇒ #f (nondecreasing? '(4 1 2 3)) ;⇒ #f</code> <hidden predikát, který pro posloupnost zjistí, zda je neklesající> <code scheme> (define nondecr1 (lambda (l) (car (foldl (lambda (e t) (cons (and (car t) (>= e (cdr t))) e)) '(#t . -999999) ;lepe: >= s -infinity? l)))) (nondecr1 '(1 2 3 4)) (nondecr1 '(1 2 4 3)) (nondecr1 '(1 2 4 3 5)) (nondecr1 '(1 2 4 4 5)) </code> TODO: reimplementovat: terminator staruje #f, pak si pamatuje predchozi, nebo nastavi #t </hidden> ======3. after, before====== Napište procedury after a before, jejichž argumenty budou element elem a seznam l . Procedura after bude vracet seznam prvku za posledním výskytem prvku elem (včetně) v seznamu l. Procedura before zase seznam prvků před prvním výskytem prvku elem (včetně) v seznamu l. Viz příklady použití: <code scheme> (after 10 '(1 2 3 4 3 5 6)) ;⇒ () (after 3 '(1 2 3 4 3 5 6)) ;⇒ (3 5 6) (after 6 '(1 2 3 4 3 5 6)) ;⇒ (6) (before 10 '(1 2 3 4 3 5 6)) ;⇒ (1 2 3 4 5 6) (before 1 '(1 2 3 4 3 5 6)) ;⇒ (1) (before 3 '(1 2 3 4 3 5 6)) ;⇒ (1 2 3)</code> <hidden procedury after, before> <code scheme> (define (after x l) ;za poslednim => po prvni od konce vcetne (let ((result (foldr (lambda (e t) ;(display t) (newline) (if (car t) t ;uz nasli, vracime porad to stejne (cons (equal? e x) (cons e (cdr t))))) '(#f . ()) l))) (if (car result) (cdr result) '()))) (after 10 '(1 2 3 10 14 15)) (define (before x l) (let ((result (foldl (lambda (e t) ;(display t) (newline) (if (car t) t ;uz nasli, vracime porad to stejne (cons (equal? e x) (cons e (cdr t))))) '(#f . ()) l))) (if (car result) (reverse (cdr result)) '()))) (before 10 '(1 2 3 10 14 15)) </code> </hidden>


Warning: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead in /data/web/virtuals/28604/virtual/www/subdom/bo/inc/auth.php on line 818
YPP1/C7R.scm.txt · Last modified: 2015/01/15 20:45 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0