Created
November 14, 2016 05:21
-
-
Save chrisbuttery/a62adbf0522b831dfc5813b72f2cd3af to your computer and use it in GitHub Desktop.
elm-pascal
This file contains 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
module Main exposing (..) | |
import Html exposing (..) | |
depth : number | |
depth = | |
10 | |
main : Html msg | |
main = | |
div [] (pascal 1 1 1) | |
pascal : Int -> Int -> Int -> List (Html msg) | |
pascal c line i = | |
let | |
message = | |
text <| toString c ++ " " | |
next = | |
if i == line then | |
1 | |
else | |
c * (line - i) // i | |
in | |
if line > depth then | |
[] | |
else if i == line then | |
message :: [ div [] (pascal 1 (line + 1) 1) ] | |
else | |
message :: pascal next line (i + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment