Last active
August 29, 2015 14:17
-
-
Save sroccaserra/5e87391640921b38c700 to your computer and use it in GitHub Desktop.
Fizzbuzz x Modoid x Elm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-- Fizzbuzz sur un monoïde ----------------------- | |
| Ensemble : le sous-ensemble de Integerzz des éléments pour lesquels "fizzbuzz" est l'indentité. | |
| Loi de composition interne : la fonction "pluzz". | |
| Élément neutre : ("fizzbuzz", 0) | |
| -----------------------------------------------------------} | |
| import Graphics.Element exposing (..) | |
| type alias Integerzz = (String, Int) | |
| fizzbuzz : Integerzz -> Integerzz | |
| fizzbuzz (_, x) = | |
| if | x % 3 == 0 && x % 5 == 0 -> ("fizzbuzz", x) | |
| | x % 3 == 0 -> ("fizz", x) | |
| | x % 5 == 0 -> ("buzz", x) | |
| | otherwise -> (toString x, x) | |
| pluzz : Integerzz -> Integerzz -> Integerzz | |
| pluzz (_, a) (_, b) = | |
| fizzbuzz ("", a + b) | |
| main : Element | |
| main = | |
| show <| pluzz ("8", 8) (pluzz ("1", 1) ("2", 2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment