diff options
| -rw-r--r-- | AufgabeFFP6.hs | 12 |
1 files 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] | |||
| 92 | yield_gtf = filt . transform . generate | 92 | yield_gtf = filt . transform . generate |
| 93 | 93 | ||
| 94 | generate :: F -> W -> (F, W, [G]) | 94 | generate :: F -> W -> (F, W, [G]) |
| 95 | --generate f w = (f, w, [ array (1,n) [ (i, j) | i<-[1..n], j<-[(+), (-), (*)] ] ] ) | 95 | generate f w = (f, w, [ array (1,n) entries | entries <- get_combinations n ] ) |
| 96 | generate f w = (f, w, [ array (1,n) [(i, j) | i<-[1..n], j<-[(+)] ] ] ) | ||
| 97 | where | 96 | where |
| 98 | n = snd $ bounds f | 97 | n = (snd $ bounds f) - 1 |
| 99 | 98 | ||
| 100 | get_combinations :: Integer -> [[(Integer, Op)]] | 99 | get_combinations :: Int -> [[(Int, Op)]] |
| 101 | get_combinations 1 = [[(1,(+))], [(1, (-))], [(1, (*))], [(1,(./.))]] | 100 | get_combinations 1 = [[(1,(+))], [(1, (-))], [(1, (*))], [(1,(./.))]] |
| 102 | get_combinations n = [ (up i) ++ entr | entr <- get_combinations (n-1), i <- get_combinations 1 ] | 101 | get_combinations n = [ (up i) ++ entr | entr <- get_combinations (n-1), i <- get_combinations 1 ] |
| 103 | where | 102 | where |
| 104 | up = map (\(num, x) -> ((num+n-1), x)) | 103 | up = map (\(num, x) -> ((num+n-1), x)) |
| 105 | 104 | ||
| 106 | --aget_combinations :: Integer -> [[Op]] | ||
| 107 | --aget_combinations 1 = [[(+)], [(-)], [(*)], [(./.)]] | ||
| 108 | --aget_combinations n = [ i ++ entr | entr <- aget_combinations (n-1), i <- aget_combinations 1 ] | ||
| 109 | |||
| 110 | |||
| 111 | transform :: (W -> (F,W,[G])) -> W -> ((F, W, [G]), [W]) | 105 | transform :: (W -> (F,W,[G])) -> W -> ((F, W, [G]), [W]) |
| 112 | transform fun w = ((f, w, g), map (eval f) g ) | 106 | transform fun w = ((f, w, g), map (eval f) g ) |
| 113 | where | 107 | where |
