Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. module Main exposing (..)
  2.  
  3. import Bitwise
  4. import Html
  5.  
  6.  
  7. -- raindrops n =
  8. -- countOnes n =
  9. -- chessboard n =
  10. -- pyramid n =
  11.  
  12.  
  13. main =
  14. -- Html.pre [] [ Html.text (raindrops 10) ]
  15. Html.pre [] [ Html.text "Zdravo Elm@FRI" ]
  16.  
  17.  
  18. raindrops n =
  19. let
  20. preveri a txt =
  21. if a == 0 then
  22. txt
  23. else if (a % 3) == 0 then
  24. preveri (a // 3) (txt ++ "Pling")
  25. else if (a % 5) == 0 then
  26. preveri (a // 5) (txt ++ "Plang")
  27. else if (a % 7) == 0 then
  28. preveri (a // 7) (txt ++ "Plong")
  29. else
  30. txt
  31. in
  32. preveri n ""
  33.  
  34.  
  35. countOnes n =
  36. let
  37. stej a c =
  38. if a > 0 then
  39. stej (Bitwise.shiftRightBy 1 a) (c + Bitwise.and a 1)
  40. else
  41. c
  42. in
  43. stej n 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement