diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-04 18:46:55 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-11-04 18:46:55 +0100 |
commit | 44fb70a695d25382640bf4772c4fd582338fa684 (patch) | |
tree | 9de33028d3ef4a5acc207a73521a126da03fdedd /ws2015/FFP/blaetter/03 | |
parent | b134b72a44119fa85ec44bcdc5e7649f354ec4bd (diff) | |
download | uni-44fb70a695d25382640bf4772c4fd582338fa684.tar uni-44fb70a695d25382640bf4772c4fd582338fa684.tar.gz uni-44fb70a695d25382640bf4772c4fd582338fa684.tar.bz2 uni-44fb70a695d25382640bf4772c4fd582338fa684.tar.xz uni-44fb70a695d25382640bf4772c4fd582338fa684.zip |
Better solutions for quadrate & alleVariablen
Diffstat (limited to 'ws2015/FFP/blaetter/03')
-rw-r--r-- | ws2015/FFP/blaetter/03/FFP_U03_Funktoren.hs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/ws2015/FFP/blaetter/03/FFP_U03_Funktoren.hs b/ws2015/FFP/blaetter/03/FFP_U03_Funktoren.hs index 935f9eb..eaa09c7 100644 --- a/ws2015/FFP/blaetter/03/FFP_U03_Funktoren.hs +++ b/ws2015/FFP/blaetter/03/FFP_U03_Funktoren.hs | |||
@@ -120,6 +120,9 @@ testb1 = testT2 == (fmap even testT1) | |||
120 | quadrate :: [Integer] | 120 | quadrate :: [Integer] |
121 | quadrate = map (2^) [0..] | 121 | quadrate = map (2^) [0..] |
122 | 122 | ||
123 | quadrate' :: [Integer] -- More efficient (probably) | ||
124 | quadrate' = 1 : [2 * x | x <- quadrate'] | ||
125 | |||
123 | -- Zum Testen: | 126 | -- Zum Testen: |
124 | q1 = take 5 quadrate | 127 | q1 = take 5 quadrate |
125 | -- > q1 | 128 | -- > q1 |
@@ -143,6 +146,16 @@ alleVariablen = seed : alleVariablen' [seed] | |||
143 | where | 146 | where |
144 | now = [v : p | v <- vars, p <- prevs] | 147 | now = [v : p | v <- vars, p <- prevs] |
145 | 148 | ||
149 | alleVariablen' :: [String] -- Preferred. | ||
150 | alleVariablen' = "" : [v : p | p <- alleVariablen', v <- vars] | ||
151 | where | ||
152 | vars = ['a', 'b', 'c', 'd'] | ||
153 | |||
154 | alleVariablen'' :: [String] | ||
155 | alleVariablen'' = [v : p | p <- "" : alleVariablen'', v <- vars] | ||
156 | where | ||
157 | vars = ['a', 'b', 'c', 'd'] | ||
158 | |||
146 | -- Zum Testen: | 159 | -- Zum Testen: |
147 | check l x = (map length . groupBy ((==) `on` length)) (take x l) | 160 | check l x = (map length . groupBy ((==) `on` length)) (take x l) |
148 | 161 | ||