const1 x = 1
square (7 + 3) = square (10) = square 10 * 10 = 100
square (7 + 3) = x * x where x = 7 + 3 = x * x where x = 10 = 10 * 10 = 100
data [a] = [] | a : [a]
[1..] > [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,{Interrupted}
[1,2..] > [1,2,3,4,5,6,... [2,1..] > [2,1,0,-1,-2,-3... [1,1..] > [1,1,1,1,1, ≡ ones = 1 : ones
nat :: [Integer] nat = nachfolger 0 where nachfolger n = n : (nachfolger (n+1))
{x | x² < 10}
[x | x <- [0..], square x < 10]
⊥, 1:⊥, 1:2:⊥, 1:2:3:⊥ ...
[ 1 , ⊥ , 3 ] ⊆ [ 1 , 2 , 3 ] und [ 1 , 2 , ⊥ ] ⊆ [ 1 , 2 , 3 ]
xs !! n = ys !! n
approx :: Integer -> [α] -> [α] approx (n+1) [] = [] approx (n+1) (x:xs) = x : approx n xs -- Hinweis: approx (n) (x:xs) = x : approx (n-1) xs ist nicht identisch
answers :: [Int] answers = 42 : answers
answers = 42 : answers answers = 42 : 42 : answers answers = 42 : 42 : 42 : answers ...
tooMuch :: String tooMuch = "You know " ++ muchMore where muchMore = "too much, " ++ muchMore
data Baum a = Knoten a [Baum a]
Knoten a []
mkBaum :: (a -> [a]) -> a -> (Baum a) -- (a -> [a]) generiert die Kinder mkBaum f x = Knoten x (map (mkBaum f) (f x)) -- unendliche Definition
genKinder :: a -> [a]
data Farbe = Leer | Schwarz | Weiss data Position = Pos { amZug :: Farbe, brett :: [Farbe]} startPosition = Pos Weiss (replicate 9 Leer) -- Ausgangspunkt der Berechnung
moeglicheZuege :: Position -> [Position]
tttBaum = mkBaum moeglicheZuege startPosition
wert :: Position -> Int wert p = Prüfe diagonal,horizontal,vertikal
werteBaum = fmap wert tttBaum
spielwert = maximiere werteBaum
spielwert = maximiere $ fmap wert $ mkBaum moeglicheZuege startPosition