Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

README 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Boom
  2. **Problem:**
  3. Return the numbers 0-n, but replace every number with a '3' as one of the digits with "Boom"
  4. I did this in the type system because I wanted to piss off my flatmate, who gave me this to try out, but also because I hate myself.
  5. I cheated a little at the end, because I cbf converting my representation to standard Church Encoding, so everything is a list of digits instead of a number.
  6. ## Running
  7. start up `ghci` and type:
  8. ```
  9. :t solution (nil :: X)
  10. ```
  11. where X is a church encoding using S as the successor function, and Z as the atom.
  12. ## Example
  13. ```
  14. :t solution (nil :: (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Z))))))))))))))))))))))))))
  15. ```
  16. will return (formatted to save your eyes):
  17. ```
  18. solution (nil :: (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S (S Z))))))))))))))))))))))))))
  19. :: Cons
  20. (Cons Z Nil)
  21. (Cons
  22. (Cons (S Z) Nil)
  23. (Cons
  24. (Cons (S (S Z)) Nil)
  25. (Cons
  26. Boom
  27. (Cons
  28. (Cons (S (S (S (S Z)))) Nil)
  29. (Cons
  30. (Cons (S (S (S (S (S Z))))) Nil)
  31. (Cons
  32. (Cons (S (S (S (S (S (S Z)))))) Nil)
  33. (Cons
  34. (Cons (S (S (S (S (S (S (S Z))))))) Nil)
  35. (Cons
  36. (Cons (S (S (S (S (S (S (S (S Z)))))))) Nil)
  37. (Cons
  38. (Cons (S (S (S (S (S (S (S (S (S Z))))))))) Nil)
  39. (Cons
  40. (Cons (S Z)
  41. (Cons Z Nil))
  42. (Cons
  43. (Cons (S Z)
  44. (Cons (S Z) Nil))
  45. (Cons
  46. (Cons (S Z)
  47. (Cons (S (S Z)) Nil))
  48. (Cons
  49. Boom
  50. (Cons
  51. (Cons (S Z)
  52. (Cons (S (S (S (S Z)))) Nil))
  53. (Cons
  54. (Cons (S Z)
  55. (Cons (S (S (S (S (S Z))))) Nil))
  56. (Cons
  57. (Cons (S Z)
  58. (Cons (S (S (S (S (S (S Z)))))) Nil))
  59. (Cons
  60. (Cons (S Z)
  61. (Cons (S (S (S (S (S (S (S Z))))))) Nil))
  62. (Cons
  63. (Cons (S Z)
  64. (Cons (S (S (S (S (S (S (S (S Z)))))))) Nil))
  65. (Cons
  66. (Cons (S Z)
  67. (Cons (S (S (S (S (S (S (S (S (S Z))))))))) Nil))
  68. (Cons
  69. (Cons (S (S Z))
  70. (Cons Z Nil))
  71. (Cons
  72. (Cons (S (S Z))
  73. (Cons (S Z) Nil))
  74. (Cons
  75. (Cons (S (S Z))
  76. (Cons (S (S Z)) Nil))
  77. (Cons
  78. Boom
  79. (Cons
  80. (Cons (S (S Z))
  81. (Cons (S (S (S (S Z)))) Nil))
  82. (Cons
  83. (Cons (S (S Z))
  84. (Cons (S (S (S (S (S Z))))) Nil))
  85. Nil)))))))))))))))))))))))))
  86. ```