From aa0d10e643990b240b3e50b4beca056c642289b0 Mon Sep 17 00:00:00 2001 From: totycro Date: Tue, 15 May 2012 03:38:48 +0200 Subject: =?UTF-8?q?Aus=20unerfindlichen=20Gr=C3=BCnden=20liefert=20yield?= =?UTF-8?q?=5Fgtf=20korrekte=20Ergebnisse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AufgabeFFP6.hs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/AufgabeFFP6.hs b/AufgabeFFP6.hs index c016dd7..1fde756 100644 --- a/AufgabeFFP6.hs +++ b/AufgabeFFP6.hs @@ -92,22 +92,16 @@ yield_gtf :: F -> W -> [G] yield_gtf = filt . transform . generate generate :: F -> W -> (F, W, [G]) ---generate f w = (f, w, [ array (1,n) [ (i, j) | i<-[1..n], j<-[(+), (-), (*)] ] ] ) -generate f w = (f, w, [ array (1,n) [(i, j) | i<-[1..n], j<-[(+)] ] ] ) +generate f w = (f, w, [ array (1,n) entries | entries <- get_combinations n ] ) where - n = snd $ bounds f + n = (snd $ bounds f) - 1 -get_combinations :: Integer -> [[(Integer, Op)]] +get_combinations :: Int -> [[(Int, Op)]] get_combinations 1 = [[(1,(+))], [(1, (-))], [(1, (*))], [(1,(./.))]] get_combinations n = [ (up i) ++ entr | entr <- get_combinations (n-1), i <- get_combinations 1 ] where up = map (\(num, x) -> ((num+n-1), x)) ---aget_combinations :: Integer -> [[Op]] ---aget_combinations 1 = [[(+)], [(-)], [(*)], [(./.)]] ---aget_combinations n = [ i ++ entr | entr <- aget_combinations (n-1), i <- aget_combinations 1 ] - - transform :: (W -> (F,W,[G])) -> W -> ((F, W, [G]), [W]) transform fun w = ((f, w, g), map (eval f) g ) where -- cgit v1.2.3