summaryrefslogtreecommitdiff
path: root/ws2015
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-11-04 18:46:55 +0100
committerGregor Kleen <gkleen@yggdrasil.li>2015-11-04 18:46:55 +0100
commit44fb70a695d25382640bf4772c4fd582338fa684 (patch)
tree9de33028d3ef4a5acc207a73521a126da03fdedd /ws2015
parentb134b72a44119fa85ec44bcdc5e7649f354ec4bd (diff)
downloaduni-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')
-rw-r--r--ws2015/FFP/blaetter/03/FFP_U03_Funktoren.hs13
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)
120quadrate :: [Integer] 120quadrate :: [Integer]
121quadrate = map (2^) [0..] 121quadrate = map (2^) [0..]
122 122
123quadrate' :: [Integer] -- More efficient (probably)
124quadrate' = 1 : [2 * x | x <- quadrate']
125
123-- Zum Testen: 126-- Zum Testen:
124q1 = take 5 quadrate 127q1 = 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
149alleVariablen' :: [String] -- Preferred.
150alleVariablen' = "" : [v : p | p <- alleVariablen', v <- vars]
151 where
152 vars = ['a', 'b', 'c', 'd']
153
154alleVariablen'' :: [String]
155alleVariablen'' = [v : p | p <- "" : alleVariablen'', v <- vars]
156 where
157 vars = ['a', 'b', 'c', 'd']
158
146-- Zum Testen: 159-- Zum Testen:
147check l x = (map length . groupBy ((==) `on` length)) (take x l) 160check l x = (map length . groupBy ((==) `on` length)) (take x l)
148 161