diff options
| author | totycro <totycro@unknown-horizons.org> | 2012-05-15 03:38:48 +0200 |
|---|---|---|
| committer | totycro <totycro@unknown-horizons.org> | 2012-05-15 03:38:48 +0200 |
| commit | aa0d10e643990b240b3e50b4beca056c642289b0 (patch) | |
| tree | b20eec1f00a80ccf84ce479ab6675890f2d8eb01 | |
| parent | ec1324e77472f183f8f3b3ab7add1b60b4f3e008 (diff) | |
| download | ffp-aa0d10e643990b240b3e50b4beca056c642289b0.tar.gz ffp-aa0d10e643990b240b3e50b4beca056c642289b0.tar.bz2 ffp-aa0d10e643990b240b3e50b4beca056c642289b0.zip | |
Aus unerfindlichen GrĂ¼nden liefert yield_gtf korrekte Ergebnisse
| -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 |
