Small changes to links and haskell comments

This commit is contained in:
Oliver Rümpelein 2016-05-25 19:28:08 +02:00
parent 03cf6a55d6
commit ea82f969f5
2 changed files with 32 additions and 9 deletions

View file

@ -28,7 +28,7 @@ using functional paradigms.
## Files ##
You may download both [the slides PDF][slides] in handout mode, and a
[source archive][source] of the examples used during the talk.
[source archive][examples] of the examples used during the talk.
## Structure ##
@ -51,7 +51,8 @@ Part Three
## Pages ##
There are two main-pages for this talk. One is my [homepage][wtfoff], the other
one is the [GitLab-server of F3L][f3lgit]
one is the [GitLab-server of F3L][f3lgit] which contains the whole example and
slide sources.
## Compiling ##
@ -80,24 +81,42 @@ lualatex -shell-escape wtfunction
### Examples ###
TBC
Exmaple 00_dafunc.cpp is not that important, and should build with any decent C++-compiler.
For the haskell-example, use `ghci`, then `:load 01_haskell.hs`. The functions provided are:
* extract (≅ fst)
* addto
* mfold (≅ foldl)
02_python.py can be executed using `python`, or inspected using `python -m`. It
provides:
* a debug-function usable as decorator
* a bubblesort-implementation using functional paradigms.
03_cpp.cpp needs a compiler capable of C++11. It shows code- and
runtime-examples for `for_each`, `transform` and `accumulate`.
04_cpp17.cpp needs a compiler capable of C++17-folds, `gcc` or `clang` should
do. Then compile using the option `std=c++1z`
## License ##
This is licensed under MIT-License. For the exact text, see License.txt.
This is licensed under MIT-License. For the exact formulation, see License.txt.
[examples]: https://www.pheerai.de/assets/wtf_examples.tar.gz
[f3l]: https://www.f3l.de
[f3lgit]: https://git.f3l.de/pheerai/wtfunctional
[fira]: https://github.com/mozilla/Fira
[haskell]: https://www.haskell.org
[inconsolata-g]: http://leonardo-m.livejournal.com/77079.html
[lualatex]: http://luatex.org
[mailto]: mailto://oli_r@fg4f.de
[mailto]: mailto:oli_r@fg4f.de
[minted]: http://github.com/gpoore/minted
[pygments]: http://pygments.org/
[python]: https://python.org/
[slides]: ??
[source]: ??
[slides]: https://www.pheerai.de/assets/wtf_slides.pdf
[texlive]: https://www.tug.org/texlive/
[wtfoff]: https://www.pheerai.de/wtf/

View file

@ -2,25 +2,29 @@ extract :: [a] -> a
extract [] = error("Too few objects")
extract (x:xs) = x
a = extract [1,2,3,4,5]
-- a == 1
-- better use fst
addto :: (Num a) => [a] -> a -> [a]
addto [] _ = [] -- edge case (list empty)
addto (x:xs) y = (x+y) : addto xs y
b = [1..4]
-- c == [5,6,7,8]
c = addto b 4
-- c == [5,6,7,8]
-- better use c = map (+4) b
-- d == [25,36,49,64]
d = map (^2) c
-- e == [6,8]
e = filter (\x -> (mod x 2) == 0) c
-- e == [6,8]
mfold :: (t -> t1 -> t1) -> t1 -> [t] -> t1
mfold f z [] = z
mfold f z (x:xs) = f x (mfold f z xs)
msum = mfold (+) 0
g = msum [1..100]
-- use sum [1..100] instead, and use right folds
pt = [(a,b,c) | a <- [1..15], b <- [1..a], c <- [1..b], a^2 == b^2 + c^2]