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:ypp1du:interlacep.scm [Bo.bule]

======interlacep.scm====== <code shell>#!/usr/bin/env racket #lang racket </code> 2. Naprogramujte predikát interlaced?, který vrací #t, pokud je jeho argument seznam liché délky (nebo je prázdný) a prvky na sudých pozicích jsou si rovny. Predikát vlastně zjištuje, jestli seznam mohl vzniknout použitím procedury interlace z předchozího příkladu. <code scheme> (define (interlace l x) (if (or (null? l) (null? (cdr l))) l;'() nebo (?): hotovo (foldr (lambda (e t) (cons e (cons x t))) (cons (car l) '());(car l) nestaci, lze i `(,(car l)) (cdr l)))) (interlace '() 'x) (interlace '(1) 'x) (interlace '(1 2) 'x) (interlace '(1 2 3) 'x) </code> predikat pro následujíci tvar: '(x ? x ? ... x ?) <code scheme> (define (x? x l) (cond ((null? l) #t) ((null? (cdr l)) #f) ;delka 1 ((equal? x (car l)) (x? x (cddr l)));ukousneme 2 a ocasni rekurze (else #f))) (x? 'x '()) ;#t (x? 'x '(x)) ;#f (x? 'x '(x 1)) ;#t (x? 'x '(x 1 x 2 x)) ;#f (x? 'x '(x 1 x 2 x 3)) ;#t (x? 'x '(x 1 x 2 y 3 y 4)) ;#f '(#t #f #t #f #t #f (testujeme x?)) (map (lambda (l) (x? 'x l)) '(() (x) (x 1) (x 1 x 2 x) (x 1 x 2 x 3) (x 1 x 2 y 3 y 4))) </code> interlaced? je varianta na x? <code scheme> (define (interlaced? l) (or (null? l) (null? (cdr l)) ;'() a (?) jsou #t (x? (cadr l) (cdr l)) ;x? inline jako named let? letrec? )) </code> Příklady použití: <code scheme> (interlaced? '()) ;⇒ #t (interlaced? (list 1)) ;⇒ #t (interlaced? (interlace (list 1 2 3) 'x)) ;⇒ #t (interlaced? '(1 x 2 x)) ;⇒ #f (interlaced? '(x 1 x 2 x)) ;⇒ #f (interlaced? '(x x x)) ;⇒ #t '(qq:) (define test1 `(() ,(list 1) ,(interlace (list 1 2 3) 'x) (1 x 2 x) (x 1 x 2 x) (x x x))) test1 '(#t #t #t #f #f #t (testujeme interlaced?)) (map interlaced? test1) ; vim: syntax=racket </code>


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/ypp1du/interlacep.scm.txt · Last modified: 2015/01/15 20:47 (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