Compare commits
3 Commits
d271eb29e9
...
674da1d686
Author | SHA1 | Date |
---|---|---|
|
674da1d686 | |
|
2de11701a8 | |
|
482042ce88 |
|
@ -0,0 +1,17 @@
|
|||
doubleAndIncrement :: Int -> Int
|
||||
|
||||
--
|
||||
-- AUFGABE BEGINNT HIER
|
||||
--
|
||||
|
||||
doubleAndIncrement =
|
||||
|
||||
--
|
||||
-- AUFGABE ENDET HIER
|
||||
--
|
||||
|
||||
|
||||
-- Test cases
|
||||
main = do
|
||||
print (doubleAndIncrement 3) -- 7
|
||||
print (doubleAndIncrement 5) -- 11
|
|
@ -0,0 +1,20 @@
|
|||
multiplyBy :: Int -> (Int -> Int)
|
||||
double :: Int -> Int
|
||||
|
||||
--
|
||||
-- AUFGABE BEGINNT HIER
|
||||
--
|
||||
|
||||
multiplyBy = -- Fill in
|
||||
double = -- Fill in using partial application
|
||||
triple = -- Fill in using partial application
|
||||
|
||||
--
|
||||
-- AUFGABE ENDET HIER
|
||||
--
|
||||
|
||||
-- Test cases
|
||||
main = do
|
||||
print (double 4) -- Expected output: 8
|
||||
print (double 7) -- Expected output: 14
|
||||
print (triple 4) -- Expected output: 12
|
|
@ -0,0 +1,22 @@
|
|||
addThreeNumbers :: Int -> Int -> Int -> Int
|
||||
addFive :: Int -> Int -> Int
|
||||
|
||||
--
|
||||
-- AUFGABE BEGINNT HIER
|
||||
--
|
||||
|
||||
addThreeNumbers = -- Fill in
|
||||
addFive = -- Fill in using partial application
|
||||
|
||||
--
|
||||
-- AUFGABE ENDET HIER
|
||||
--
|
||||
|
||||
|
||||
|
||||
-- Test cases
|
||||
main = do
|
||||
print (addThreeNumbers 3 2 4) -- 9
|
||||
print (addThreeNumbers 7 6 4) -- 17
|
||||
print (addFive 3 2) -- 10
|
||||
print (addFive 1 4) -- 10
|
|
@ -0,0 +1,21 @@
|
|||
module Main where
|
||||
|
||||
-- Definiert einen simplen container für unsere Werte
|
||||
data Box a = Box a deriving (Show, Eq)
|
||||
|
||||
-- Schreibe die Unit funktion, welche einen Wert in einen Container verschachtelt!
|
||||
unit :: a -> Box a
|
||||
|
||||
|
||||
-- Schreibe die Bind Funktion, welches es einem Erlaubt
|
||||
bind :: Box a -> (a -> Box b) -> Box b
|
||||
|
||||
|
||||
-- Schreibe eine Lift Funktion, welche eine Funtion nimmt und diesselbe funktion mit den Monadischen Werten als Eigabe und Ausgabetyp besitzt
|
||||
lift :: (a -> b) -> Box a -> Box b
|
||||
|
||||
|
||||
-- Main Function to run tests
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ unit 10 -- Box 10
|
|
@ -0,0 +1,21 @@
|
|||
module Main where
|
||||
|
||||
-- Definiere eine einfache Datenstruktur für DOM-Elemente
|
||||
data DOM a = Element a [DOM a] | EmptyElement deriving (Show, Eq)
|
||||
|
||||
-- Schreibe die Unit funktion, welche einen Wert in einen DOM-Container verschachtelt!
|
||||
unit :: a -> DOM a
|
||||
|
||||
|
||||
-- Schreibe die Bind Funktion, welches es einem Erlaubt funktionen des Monadischen Typen DOM zu verketten
|
||||
bind :: DOM a -> (a -> DOM b) -> DOM b
|
||||
|
||||
|
||||
-- Schreibe eine Lift Funktion, welche eine Funtion nimmt und diesselbe funktion mit den Monadischen Werten DOM als Eigabe und Ausgabetyp besitzt
|
||||
lift :: (a -> b) -> DOM a -> DOM b
|
||||
|
||||
|
||||
-- Hauptfunktion zum Ausführen von Tests
|
||||
main :: IO ()
|
||||
main = do
|
||||
print $ unit "root" -- Element "root" []
|
Loading…
Reference in New Issue