Advertisement
Guest User

Week 5

a guest
Dec 16th, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.30 KB | None | 0 0
  1. :: week 5a
  2. :: ~figrum-lonlug
  3. ::
  4. :: create a gate with atom sample
  5. ::
  6. |= n=@
  7. ::
  8. :: execute 'goldbach' arm passing sample in
  9. :: but first, add the core below to the subject
  10. ::
  11. =< (goldbach n)
  12. |%
  13. ++ prime
  14. :: take an atom, return a flag
  15. ::
  16. |= n=@
  17. ^- ?
  18. ::
  19. :: some edge cases:
  20. :: <2, not prime
  21. :: >=2 and <4, prime
  22. ::
  23. ?: (lth n 2) |
  24. ?: (lth n 4) &
  25. ::
  26. :: add two atoms to the subject
  27. :: 'i' lower order factor
  28. :: 'j' higher order factor
  29. ::
  30. =/ i=@ 2
  31. =/ j=@ 2
  32. ::
  33. :: recurse to here
  34. ::
  35. |- ^- ?
  36. ::
  37. :: if the factors produce 'n',
  38. :: then n cannot be prime
  39. ::
  40. ?: =((mul i j) n) |
  41. ::
  42. :: if 'j' has reached half the value
  43. :: of 'n' then we have exhausted every
  44. :: possible pair of factors and the
  45. :: 'n' is prime
  46. ::
  47. ?: =(j (div n 2)) &
  48. ::
  49. :: if the current pair of factors have
  50. :: overshot 'n' reset 'i' (the lower order factor)
  51. :: and increment 'j' (the higher order one)
  52. ::
  53. ?: (gth (mul i j) n)
  54. $(i 2, j +(j))
  55. ::
  56. :: otherwise, just increment by one
  57. ::
  58. $(i +(i))
  59. ++ goldbach
  60. :: declare a gate with atom sample
  61. ::
  62. |= n=@
  63. ::
  64. :: return type is a union, it can be:
  65. :: 1. a flag
  66. :: OR
  67. :: 2. a cell with:
  68. :: head: cell of atoms
  69. :: tail: flag
  70. ::
  71. ^- ?(? [[@ @] ?])
  72. ::
  73. :: if the input is <4 or odd then it is not a valid
  74. :: objection
  75. ::
  76. ?: |((lth n 4) =((mod n 2) 1)) |
  77. ::
  78. :: add two atoms to the subject
  79. :: summed, these values are always
  80. :: equal to 'n'
  81. ::
  82. =/ i=@ 2
  83. =/ j=@ (sub n 2)
  84. ::
  85. :: recurse to here
  86. ::
  87. |- ^- ?(? [[@ @] ?])
  88. ::
  89. :: if the two addends are prime, the conjecture stands
  90. ::
  91. ?: &((prime i) (prime j)) [[i j] |]
  92. ::
  93. :: if 'i' has reached its maximum, we have a true
  94. :: objection
  95. ::
  96. ?: =((add 2 i) n) &
  97. ::
  98. :: otherwise try new values, ensuring they still sum to the same
  99. :: value, 'n'
  100. ::
  101.  
  102. :: week 5b
  103. :: ~figrum-lonlug
  104. ::
  105. |= raw=tape
  106. ^- tape
  107. =<
  108. :: promote all the sub tapes into a single tape
  109. ::
  110. %- zing
  111. ::
  112. :: place a tape of 2 spaces between each signal
  113. ::
  114. %+ join " "
  115. ::
  116. :: give input to convert in uppercase
  117. ::
  118. (convert (cuss raw))
  119. ::
  120. |%
  121. ++ convert
  122. |= t=tape
  123. |- ^- (list tape)
  124. ?~ t
  125. ~
  126. :-
  127. :: make tape
  128. ::
  129. %- trip
  130. ::
  131. :: provide a legible default
  132. :: for unhandled characters
  133. ::
  134. %+ fall
  135. (~(get by table) i.t)
  136. '?'
  137. $(t t.t)
  138. ++ table
  139. %- my
  140. :~ :- 'A' '.-'
  141. :- 'B' '-...'
  142. :- 'C' '-.-.'
  143. :- 'D' '-..'
  144. :- 'E' '.'
  145. :- 'F' '..-.'
  146. :- 'G' '--.'
  147. :- 'H' '....'
  148. :- 'I' '..'
  149. :- 'J' '.---'
  150. :- 'K' '-.-'
  151. :- 'L' '.-..'
  152. :- 'M' '--'
  153. :- 'N' '-.'
  154. :- 'O' '---'
  155. :- 'P' '.--.'
  156. :- 'Q' '--.-'
  157. :- 'R' '.-.'
  158. :- 'S' '...'
  159. :- 'T' '-'
  160. :- 'U' '..-'
  161. :- 'V' '...-'
  162. :- 'W' '.--'
  163. :- 'X' '-..-'
  164. :- 'Y' '-.--'
  165. :- 'Z' '--..'
  166. :- '0' '-----'
  167. :- '1' '.----'
  168. :- '2' '..---'
  169. :- '3' '...--'
  170. :- '4' '....-'
  171. :- '5' '.....'
  172. :- '6' '-....'
  173. :- '7' '--...'
  174. :- '8' '---..'
  175. :- '9' '----.'
  176. ==
  177. --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement