Commit abe31bb1 by Jochen Schulz

### actual state

parent c5df575c
 ... ... @@ -32,6 +32,7 @@ A lecture to teach Haskell in a 2 weeks block lab course. * [26 continous optimization](http://nbviewer.jupyter.org/urls/gitlab.gwdg.de/jschulz1/haskell_labcourse/raw/master/lecture/26 continous optimization.ipynb) * [27 inverse](http://nbviewer.jupyter.org/urls/gitlab.gwdg.de/jschulz1/haskell_labcourse/raw/master/lecture/27 inverse.ipynb) * [28 minsurf](http://nbviewer.jupyter.org/urls/gitlab.gwdg.de/jschulz1/haskell_labcourse/raw/master/lecture/28 minsurf.ipynb) * [Untitled](http://nbviewer.jupyter.org/urls/gitlab.gwdg.de/jschulz1/haskell_labcourse/raw/master/lecture/Untitled.ipynb) * [shortest path](http://nbviewer.jupyter.org/urls/gitlab.gwdg.de/jschulz1/haskell_labcourse/raw/master/lecture/shortest path.ipynb) ## viewing of the notebooks ... ...
 # vim:ft=todo TODO 2016-03-17 notebook-convertierungen ! lhs <-> ipynb - motivation fuer haskell: funktionale/mathematische Sichtweise LECTURE: ... ...
 ... ... @@ -21,8 +21,6 @@ facRf x = fac' x 1 where fac' 1 y = y fac' f y = fac' (f-1) \$! (f*y) Fractional main :: IO () main = do let g = facNE 10000 ... ...
 %% Cell type:markdown id: tags: # Excercises: types %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 1 Use [Hoogle](https://www.haskell.org/hoogle/) or [Hayoo!](http://hayoo.fh-wedel.de/): - What is the difference between `div` and `quot`? - Find the definition of the type `Bool` in `GHC.Types`. - Find `(<=)`. Why is there no implementation? %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 2 Use the function `factorial` from the lecture, ```haskell factorial :: Integer -> Integer factorial n = product [1.. n] ``` and change the type to `Int -> Int`. Which consequences does this have, and how can you show it? %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 3 - Write a function taking two numbers as arguments, the edge lengths of a rectangle, and returns the area. - the function should be able to work with arbitrary type of numbers (besides complex) %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 4 Write a function accepting three strings and returning the lexicographically largest one. %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 5 Write a function accepting a list of arbitrary numbers and returning the mean value. %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 6 Write a function that accepts a number and a tuple (e.g. `("left", "right")`) and returns the first element of the tuple if the digit `0` is in the number, and the second element otherwise. %% Cell type:code id: tags: ``` haskell ``` ... ...
 %% Cell type:markdown id: tags: # Exercises: higher order functions ## problem 1 - write a function `applyThrice` analogous to `applyTwice` from the lecture. - write a function `applyThrice'` without using an argument, thus ```haskell applyThrice' f = ... ``` %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 2 write in pointfree-style: - `f x = (+) 5 \$ (/) 8 x` - `g x = mod 4 \$ div 16 \$ 2 * \$ x + 2` - `g x = mod 4 \$ div 16 \$ (2 *) \$ x + 2` %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 3 write the following functions as lambda functions - \$h(x) = x^2 + x \% 5\$. - the `hasVowal` function. %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 4 Write a function `gt100`, which checks if a parameter is greater than 100 - normal - pointfree - as anonymous - as pointfree anonymous function %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 5 Let ```haskell multThree :: (Num a) => a -> a -> a -> a multThree x y z = x * y * z ``` be a function for multiplying three numbers with each other. Use partial function evaluation to get a function which has one parameter and multiplies with 49. %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 6 - write a function `flipFunct`, which gets a function of two arguments and returns a function which has the arguments flipped. - check the function with the `-` %% Cell type:code id: tags: ``` haskell ``` %% Cell type:markdown id: tags: ## problem 7 rewrite the following function such that it only contains function composition and application operators. Avoid as usual brackets. ```haskell oddity = (odd(negate(sum (take 3 [1..])))) ``` %% Cell type:code id: tags: ``` haskell ``` ... ...