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: 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 656

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 656
YPP1:K4b.scm

======K4b.scm====== <code shell>#!/usr/bin/env racket #lang racket/base </code> ====== fac ====== <code scheme> (define ! (lambda (n) (if (= n 0) 1 (* n (! (- n 1)))))) </code> ====== fac-iter ====== <code scheme> (define !iter (lambda (a i) (if (= i 0) a (!iter (* a i) (- i 1))))) (define !* (lambda(n) (!iter 1 n))) (define !iter (lambda (a i) (display "a: ") (display a) (newline) (display "i: ") (display i) (newline) (newline) (if (= i 0) a (!iter (* a i) (- i 1))))) </code> ====== merge ====== <code scheme> (define merge (lambda (l1 l2 order) (cond ((null? l1) l2) ((null? l2) l1) ((order (car l1) (car l2)) (cons (car l1) (merge (cdr l1) l2 order))) (else (cons (car l2) (merge (cdr l2) l1 order)))))) </code> ====== split ====== <code scheme> (define split (lambda (l) (split-pomocna l () ()))) </code> ====== split-pomocna ====== <code scheme> (define split-pomocna (lambda (l l1 l2) (if (null? l) (cons l1 l2) (split-pomocna (cdr l) (cons (car l) l2) l1)))) </code> ====== mergesort ====== <code scheme> (define mergesort (lambda (l order) (if (or (null? l) (null? (cdr l))) l (let* ((l1l2 (split l)) (l1 (car l1l2)) (l2 (cdr l1l2))) (merge (mergesort l1 order) (mergesort l2 order) order))))) </code> ====== abc-string ====== <code scheme> (define abc-string "aábcčdďeéěfghiíjklmnňoópqrřsštťuůúvwxyýzž") </code> ====== abc-assoc1 ====== <code scheme> (define abc-assoc1 (let* ((lst (string->list abc-string)) (len (length lst))) (map cons lst (build-list len +)))) </code> ====== my-assoc2 ====== <code scheme> (define my-assoc2 (lambda (e l) (cond ((null? l) #f) ((equal? e (caar l)) (car l)) (else (my-assoc e (cdr l)))))) </code> ====== my-assoc ====== <code scheme> (define my-assoc (lambda (e l) (if (null? l) #f (if (equal? e (caar l)) (car l) (my-assoc e (cdr l)))))) </code> ====== index-of ====== <code scheme> (define index-of (lambda (c) (cdr (my-assoc c abc-assoc)))) </code> ====== compare-strings-cz ====== <code scheme> (define compare-strings-cz (lambda (s1 s2) (compare-strings-cz-aux (string->list s1) (string->list s2) ))) </code> ====== compare-strings-cz-aux ====== <code scheme> (define compare-strings-cz-aux (lambda (l1 l2) (cond ((null? l1) #t) ((null? l2) #f) ((< (index-of (car l1)) (index-of (car l2))) #t) ((> (index-of (car l1)) (index-of (car l2))) #f) (else (compare-strings-cz-aux (cdr l1) (cdr l2)))))) (compare-strings-cz "svete" "áhoj" ) </code> ====== merge-sort ====== <code scheme> (mergesort '("ahoj" "člověče" "xxx" "ššš") compare-strings-cz) ; vim: syntax=racket </code>