Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. module Main exposing (..)
  2.  
  3. import Html exposing (..)
  4.  
  5.  
  6. depth : number
  7. depth =
  8. 10
  9.  
  10.  
  11. main : Html msg
  12. main =
  13. div [] (pascal 1 1 1)
  14.  
  15.  
  16. pascal : Int -> Int -> Int -> List (Html msg)
  17. pascal c line i =
  18. let
  19. message =
  20. text <| toString c ++ " "
  21.  
  22. next =
  23. if i == line then
  24. 1
  25. else
  26. c * (line - i) // i
  27. in
  28. if line > depth then
  29. []
  30. else if i == line then
  31. message :: [ div [] (pascal 1 (line + 1) 1) ]
  32. else
  33. message :: pascal next line (i + 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement