From 9477dbe667f250ecd23f8fc0d56b942191526421 Mon Sep 17 00:00:00 2001 From: Franciszek Malinka Date: Thu, 25 Feb 2021 14:42:55 +0100 Subject: Stare semestry, niepoukladane --- Semestr 2/racket/l11/rozw.bak | 2 + Semestr 2/racket/l11/rozw.rkt | 776 ++++++++++++++++++++++++++++++++++++++ Semestr 2/racket/l11/solution.bak | 18 + Semestr 2/racket/l11/solution.rkt | 35 ++ 4 files changed, 831 insertions(+) create mode 100644 Semestr 2/racket/l11/rozw.bak create mode 100644 Semestr 2/racket/l11/rozw.rkt create mode 100644 Semestr 2/racket/l11/solution.bak create mode 100644 Semestr 2/racket/l11/solution.rkt (limited to 'Semestr 2/racket/l11') diff --git a/Semestr 2/racket/l11/rozw.bak b/Semestr 2/racket/l11/rozw.bak new file mode 100644 index 0000000..cda82ce --- /dev/null +++ b/Semestr 2/racket/l11/rozw.bak @@ -0,0 +1,2 @@ +#lang racket + diff --git a/Semestr 2/racket/l11/rozw.rkt b/Semestr 2/racket/l11/rozw.rkt new file mode 100644 index 0000000..e45e403 --- /dev/null +++ b/Semestr 2/racket/l11/rozw.rkt @@ -0,0 +1,776 @@ +#reader(lib"read.ss""wxme")WXME0109 ## +#| + This file uses the GRacket editor format. + Open this file in DrRacket version 7.6 or later to read it. + + Most likely, it was created by saving a program in DrRacket, + and it probably contains a program with non-text elements + (such as images or comment boxes). + + http://racket-lang.org/ +|# + 33 7 #"wxtext\0" +3 1 6 #"wxtab\0" +1 1 8 #"wximage\0" +2 0 8 #"wxmedia\0" +4 1 34 #"(lib \"syntax-browser.ss\" \"mrlib\")\0" +1 0 36 #"(lib \"cache-image-snip.ss\" \"mrlib\")\0" +1 0 68 +(0 + #"((lib \"image-core.ss\" \"mrlib\") (lib \"image-core-wxme.rkt\" \"mr" + #"lib\"))\0" +) 1 0 16 #"drscheme:number\0" +3 0 44 #"(lib \"number-snip.ss\" \"drscheme\" \"private\")\0" +1 0 36 #"(lib \"comment-snip.ss\" \"framework\")\0" +1 0 93 +(1 + #"((lib \"collapsed-snipclass.ss\" \"framework\") (lib \"collapsed-sni" + #"pclass-wxme.ss\" \"framework\"))\0" +) 0 0 43 #"(lib \"collapsed-snipclass.ss\" \"framework\")\0" +0 0 19 #"drscheme:sexp-snip\0" +0 0 29 #"drscheme:bindings-snipclass%\0" +1 0 101 +(2 + #"((lib \"ellipsis-snip.rkt\" \"drracket\" \"private\") (lib \"ellipsi" + #"s-snip-wxme.rkt\" \"drracket\" \"private\"))\0" +) 2 0 88 +(3 + #"((lib \"pict-snip.rkt\" \"drracket\" \"private\") (lib \"pict-snip.r" + #"kt\" \"drracket\" \"private\"))\0" +) 0 0 55 +#"((lib \"snip.rkt\" \"pict\") (lib \"snip-wxme.rkt\" \"pict\"))\0" +1 0 34 #"(lib \"bullet-snip.rkt\" \"browser\")\0" +0 0 25 #"(lib \"matrix.ss\" \"htdp\")\0" +1 0 22 #"drscheme:lambda-snip%\0" +1 0 29 #"drclickable-string-snipclass\0" +0 0 26 #"drracket:spacer-snipclass\0" +0 0 57 +#"(lib \"hrule-snip.rkt\" \"macro-debugger\" \"syntax-browser\")\0" +1 0 26 #"drscheme:pict-value-snip%\0" +0 0 45 #"(lib \"image-snipr.ss\" \"slideshow\" \"private\")\0" +1 0 38 #"(lib \"pict-snipclass.ss\" \"slideshow\")\0" +2 0 55 #"(lib \"vertical-separator-snip.ss\" \"stepper\" \"private\")\0" +1 0 18 #"drscheme:xml-snip\0" +1 0 31 #"(lib \"xml-snipclass.ss\" \"xml\")\0" +1 0 21 #"drscheme:scheme-snip\0" +2 0 34 #"(lib \"scheme-snipclass.ss\" \"xml\")\0" +1 0 10 #"text-box%\0" +1 0 32 #"(lib \"text-snipclass.ss\" \"xml\")\0" +1 0 1 6 #"wxloc\0" + 0 0 81 0 1 #"\0" +0 75 1 #"\0" +0 10 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 0 9 +#"Standard\0" +0 75 12 #"Courier New\0" +0 16 90 -1 90 -1 3 -1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 255 255 255 1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 -1 -1 2 24 +#"framework:default-color\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 150 0 150 0 0 0 -1 -1 2 15 +#"text:ports out\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 34 119 34 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1.0 0 -1 -1 93 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 255 0 0 0 0 0 -1 +-1 2 15 #"text:ports err\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 204 204 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 175 0 0 0 -1 -1 2 17 +#"text:ports value\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1 +-1 2 27 #"Matching Parenthesis Style\0" +0 -1 1 #"\0" +1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 34 139 34 0 0 0 -1 +-1 2 1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 38 38 128 0 0 0 -1 -1 2 37 +#"framework:syntax-color:scheme:symbol\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +38 #"framework:syntax-color:scheme:keyword\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 194 116 31 0 0 0 -1 -1 2 +38 #"framework:syntax-color:scheme:comment\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 204 221 170 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 41 128 38 0 0 0 -1 -1 2 37 +#"framework:syntax-color:scheme:string\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +35 #"framework:syntax-color:scheme:text\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +39 #"framework:syntax-color:scheme:constant\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 132 60 36 0 0 0 -1 -1 2 49 +#"framework:syntax-color:scheme:hash-colon-keyword\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +42 #"framework:syntax-color:scheme:parenthesis\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 178 178 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 2 36 +#"framework:syntax-color:scheme:error\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 204 204 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 -1 -1 2 36 +#"framework:syntax-color:scheme:other\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 144 179 255 0 0 0 -1 -1 2 +16 #"Misspelled Text\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 81 112 203 0 0 0 -1 -1 2 +38 #"drracket:check-syntax:lexically-bound\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 50 163 255 0 0 0 -1 -1 2 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 178 34 34 0 0 0 -1 -1 2 28 +#"drracket:check-syntax:set!d\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 204 204 0 0 0 -1 -1 2 +37 #"drracket:check-syntax:unused-require\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 204 204 0 0 0 -1 -1 2 +36 #"drracket:check-syntax:free-variable\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 204 204 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 68 0 203 0 0 0 -1 -1 2 31 +#"drracket:check-syntax:imported\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 166 0 255 0 0 0 -1 -1 2 47 +#"drracket:check-syntax:my-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 192 203 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 0 116 0 0 0 0 -1 -1 2 50 +#"drracket:check-syntax:their-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 50 205 50 0 0 0 -1 -1 2 48 +#"drracket:check-syntax:unk-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 139 142 28 0 0 0 -1 -1 2 +49 #"drracket:check-syntax:both-obligation-style-pref\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 240 230 140 0 0 0 -1 -1 2 +26 #"plt:htdp:test-coverage-on\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 255 165 0 0 0 0 -1 -1 2 27 +#"plt:htdp:test-coverage-off\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 205 92 92 0 0 0 -1 -1 4 1 +#"\0" +0 70 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 4 4 #"XML\0" +0 70 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 2 37 #"plt:module-language:test-coverage-on\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 2 +38 #"plt:module-language:test-coverage-off\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 93 -1 -1 0 1 0 0 0 1 0 0 0 0 0 0 205 92 92 0 0 0 -1 -1 0 36 +#"mrlib/syntax-browser:subtitle-color\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 100 149 237 0 0 0 -1 -1 0 +42 #"mrlib/syntax-browser:focused-syntax-color\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 50 205 50 0 0 0 -1 -1 4 1 +#"\0" +0 71 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 4 1 #"\0" +0 -1 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 191 255 0 0 0 -1 +-1 4 1 #"\0" +0 71 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 1 0 0 0 0 0 0 0 0 1.0 1.0 1.0 0 191 255 0 0 0 -1 +-1 4 1 #"\0" +0 71 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1.0 1.0 1.0 152 251 152 0 0 0 +-1 -1 4 32 #"widget.rkt::browser-text% basic\0" +0 70 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 4 59 +#"macro-debugger/syntax-browser/properties color-text% basic\0" +0 70 1 #"\0" +1.0 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 1.0 1.0 1.0 1.0 1.0 1.0 0 0 0 0 0 0 +-1 -1 58 1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 190 190 190 0 0 0 -1 -1 2 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 0 0 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 255 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 0 0 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 0 0 255 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 185 220 113 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 155 255 155 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 116 116 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 18 67 155 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 30 70 190 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 75 135 185 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 176 208 208 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 116 116 255 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 200 125 255 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 143 15 223 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 165 0 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 141 19 5 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 244 194 71 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 255 255 127 0 0 0 -1 -1 4 +1 #"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 0 0 0 0 1 1 1 86 86 86 0 0 0 -1 -1 4 1 +#"\0" +0 -1 1 #"\0" +1 0 -1 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 255 255 255 0 31 31 -1 -1 +4 1 #"\0" +0 -1 1 #"\0" +1.0 0 92 -1 -1 -1 -1 -1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 255 255 0 -1 -1 + 0 475 0 28 3 12 #"#lang racket" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 7 #"require" +0 0 24 3 1 #" " +0 0 14 3 15 #"racket/contract" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 17 3 13 #";;; Zadanie 1" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 8 #"suffixes" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 6 #"listof" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 3 #") (" +0 0 14 3 6 #"listof" +0 0 24 3 2 #" (" +0 0 14 3 6 #"listof" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 5 #")))) " +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 2 #"if" +0 0 24 3 2 #" (" +0 0 14 3 5 #"null?" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 6 #" " +0 0 14 3 4 #"null" +0 0 24 29 1 #"\n" +0 0 24 3 7 #" (" +0 0 14 3 4 #"cons" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 2 #" (" +0 0 14 3 8 #"suffixes" +0 0 24 3 2 #" (" +0 0 14 3 3 #"cdr" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 5 #")))))" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 17 3 13 #";;; Zadanie 2" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 8 #"sublists" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 6 #"listof" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 3 #") (" +0 0 14 3 6 #"listof" +0 0 24 3 2 #" (" +0 0 14 3 6 #"listof" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 6 #")))) " +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 2 #"if" +0 0 24 3 2 #" (" +0 0 14 3 5 #"null?" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 7 #" (" +0 0 14 3 4 #"list" +0 0 24 3 1 #" " +0 0 14 3 4 #"null" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 7 #" (" +0 0 14 3 10 #"append-map" +0 0 24 29 1 #"\n" +0 0 24 3 8 #" (" +0 0 15 3 6 #"lambda" +0 0 24 3 2 #" (" +0 0 14 3 2 #"ys" +0 0 24 3 3 #") (" +0 0 14 3 4 #"list" +0 0 24 3 2 #" (" +0 0 14 3 4 #"cons" +0 0 24 3 2 #" (" +0 0 14 3 3 #"car" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 2 #") " +0 0 14 3 2 #"ys" +0 0 24 3 2 #") " +0 0 14 3 2 #"ys" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 3 8 #" (" +0 0 14 3 8 #"sublists" +0 0 24 3 2 #" (" +0 0 14 3 3 #"cdr" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 5 #")))))" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 17 3 13 #";;; Zadanie 3" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 17 #"autistic-identity" +0 0 24 3 1 #" " +0 0 14 3 1 #"x" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 3 2 #" " +0 0 14 3 1 #"x" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 6 #"create" +0 0 24 3 1 #" " +0 0 14 3 4 #"comb" +0 0 24 3 1 #" " +0 0 14 3 4 #"next" +0 0 24 3 1 #" " +0 0 14 3 3 #"beg" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 1 #" " +0 0 14 3 1 #"c" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 1 #" " +0 0 14 3 1 #"c" +0 0 24 3 3 #") (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 2 #") " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"c" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 3 4 #" ((" +0 0 14 3 4 #"comb" +0 0 24 3 2 #" (" +0 0 14 3 4 #"next" +0 0 24 3 1 #" " +0 0 14 3 3 #"beg" +0 0 24 3 2 #") " +0 0 14 3 3 #"beg" +0 0 24 3 3 #")))" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 7 #"compose" +0 0 24 3 1 #" " +0 0 14 3 2 #"bc" +0 0 24 3 1 #" " +0 0 14 3 2 #"ab" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 1 #" " +0 0 14 3 1 #"c" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 1 #" " +0 0 14 3 1 #"c" +0 0 24 3 3 #") (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 3 #") (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"c" +0 0 24 3 3 #")))" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 15 3 6 #"lambda" +0 0 24 3 2 #" (" +0 0 14 3 1 #"x" +0 0 24 3 3 #") (" +0 0 14 3 2 #"bc" +0 0 24 3 2 #" (" +0 0 14 3 2 #"ab" +0 0 24 3 1 #" " +0 0 14 3 1 #"x" +0 0 24 3 4 #"))))" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 5 #"ident" +0 0 24 3 1 #" " +0 0 14 3 1 #"f" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 2 #") " +0 0 14 3 1 #"a" +0 0 24 3 2 #") " +0 0 14 3 1 #"a" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 1 #"f" +0 0 24 3 1 #" " +0 0 14 3 8 #"identity" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 17 3 13 #";;; Zadanie 4" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 12 #"broken-contr" +0 0 24 3 1 #" " +0 0 14 3 1 #"x" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 1 #"b" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 12 #"broken-contr" +0 0 24 3 1 #" " +0 0 14 3 1 #"x" +0 0 24 3 2 #"))" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 17 3 13 #";;; Zadanie 5" +0 0 24 29 1 #"\n" +0 0 24 29 1 #"\n" +0 0 24 3 1 #"(" +0 0 15 3 15 #"define/contract" +0 0 24 3 2 #" (" +0 0 14 3 9 #"foldl-map" +0 0 24 3 1 #" " +0 0 14 3 1 #"f" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 14 #"parametric->/c" +0 0 24 3 2 #" [" +0 0 14 3 1 #"F" +0 0 24 3 1 #" " +0 0 14 3 1 #"A" +0 0 24 3 1 #" " +0 0 14 3 1 #"L" +0 0 24 3 3 #"] (" +0 0 14 3 2 #"->" +0 0 24 3 2 #" (" +0 0 14 3 2 #"->" +0 0 24 3 1 #" " +0 0 14 3 1 #"L" +0 0 24 3 1 #" " +0 0 14 3 1 #"A" +0 0 24 3 2 #" (" +0 0 14 3 6 #"cons/c" +0 0 24 3 1 #" " +0 0 14 3 1 #"F" +0 0 24 3 1 #" " +0 0 14 3 1 #"A" +0 0 24 3 3 #")) " +0 0 14 3 1 #"A" +0 0 24 3 2 #" (" +0 0 14 3 6 #"listof" +0 0 24 3 1 #" " +0 0 14 3 1 #"L" +0 0 24 3 3 #") (" +0 0 14 3 6 #"cons/c" +0 0 24 3 2 #" (" +0 0 14 3 6 #"listof" +0 0 24 3 1 #" " +0 0 14 3 1 #"F" +0 0 24 3 2 #") " +0 0 14 3 1 #"A" +0 0 24 3 4 #"))) " +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 15 3 6 #"define" +0 0 24 3 2 #" (" +0 0 14 3 2 #"it" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #" " +0 0 14 3 2 #"ys" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 5 #" (" +0 0 14 3 2 #"if" +0 0 24 3 2 #" (" +0 0 14 3 5 #"null?" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 9 #" (" +0 0 14 3 4 #"cons" +0 0 24 3 2 #" (" +0 0 14 3 7 #"reverse" +0 0 24 3 1 #" " +0 0 14 3 2 #"ys" +0 0 24 3 2 #") " +0 0 14 3 1 #"a" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 9 #" (" +0 0 15 3 3 #"let" +0 0 24 3 3 #" [(" +0 0 14 3 1 #"p" +0 0 24 3 2 #" (" +0 0 14 3 1 #"f" +0 0 24 3 2 #" (" +0 0 14 3 3 #"car" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 2 #") " +0 0 14 3 1 #"a" +0 0 24 3 3 #"))]" +0 0 24 29 1 #"\n" +0 0 24 3 11 #" (" +0 0 14 3 2 #"it" +0 0 24 3 2 #" (" +0 0 14 3 3 #"cdr" +0 0 24 3 1 #" " +0 0 14 3 1 #"p" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 15 #" (" +0 0 14 3 3 #"cdr" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #")" +0 0 24 29 1 #"\n" +0 0 24 3 15 #" (" +0 0 14 3 4 #"cons" +0 0 24 3 2 #" (" +0 0 14 3 3 #"car" +0 0 24 3 1 #" " +0 0 14 3 1 #"p" +0 0 24 3 2 #") " +0 0 14 3 2 #"ys" +0 0 24 3 5 #")))))" +0 0 24 29 1 #"\n" +0 0 24 3 3 #" (" +0 0 14 3 2 #"it" +0 0 24 3 1 #" " +0 0 14 3 1 #"a" +0 0 24 3 1 #" " +0 0 14 3 2 #"xs" +0 0 24 3 1 #" " +0 0 14 3 4 #"null" +0 0 24 3 2 #"))" +0 0 diff --git a/Semestr 2/racket/l11/solution.bak b/Semestr 2/racket/l11/solution.bak new file mode 100644 index 0000000..3ae167a --- /dev/null +++ b/Semestr 2/racket/l11/solution.bak @@ -0,0 +1,18 @@ +#lang racket + +(require racket/contract) + +(provide (contract-out [square square/c])) +(provide square/c) + +(define square/c (-> number? (not/c negative?))) + +(define (square x) (* x x)) + + +(define with-labels/c (parametric->/c [a b] (-> (-> a b)) + +(define (with-labels f xs) + (if (null? xs) + null + (cons (list (f (car xs)) (car xs)) (with-labels f (cdr xs))))) \ No newline at end of file diff --git a/Semestr 2/racket/l11/solution.rkt b/Semestr 2/racket/l11/solution.rkt new file mode 100644 index 0000000..55e4ba6 --- /dev/null +++ b/Semestr 2/racket/l11/solution.rkt @@ -0,0 +1,35 @@ +#lang racket + +(provide (contract-out + [with-labels with-labels/c] + [foldr-map foldr-map/c] + [pair-from pair-from/c])) +(provide with-labels/c foldr-map/c pair-from/c) + + +(define with-labels/c (parametric->/c [a b] (-> (-> a b) (listof a) (listof (cons/c b (cons/c a null?)))))) + +(define (with-labels f xs) + (if (null? xs) + null + (cons (list (f (car xs)) (car xs)) (with-labels f (cdr xs))))) + + + +(define foldr-map/c (parametric->/c [x a f] (-> (-> x a (cons/c f a)) a (listof x) (cons/c (listof f) a)))) + +(define (foldr-map f a xs) + (define (it a xs ys) + (if (null? xs) + (cons ys a) + (let [(p (f (car xs) a))] + (it (cdr p) + (cdr xs) + (cons (car p) ys))))) + (it a (reverse xs) null)) + + +(define pair-from/c (parametric->/c [x fx gx] (-> (-> x fx) (-> x gx) (-> x (cons/c fx gx))))) + +(define (pair-from f g) + (lambda (x) (cons (f x) (g x)))) \ No newline at end of file -- cgit v1.2.3