Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PART 1
- :: Define a gate that takes an atom with face 'n' as the argument
- ::
- |= n=@
- :: This rune evaluates the second child expression before executing the first child expression with the result as the subject. This allows the first child expression to reference faces in the second child expression. The first child expression is calling the arm 'goldbach' with 'n' as the argument
- ::
- =< (goldbach n)
- :: This rune produces a core
- ::
- |%
- :: This is the first arm definition of the core with face 'prime'
- ::
- ++ prime
- :: It defines a gate that accepts an atom with face 'n'
- ::
- |= n=@
- :: This rune casts the gate to the boolean type
- ::
- ^- ?
- :: This conditional evaluates to false if 'n' is < 2
- ::
- ?: (lth n 2) |
- :: Else if 'n' is less than 4 it evaultes to true.
- ::
- ?: (lth n 4) &
- :: Otherwise, continue to store the value 2 as an atom with face 'i'
- ::
- =/ i=@ 2
- :: Store the value 2 as an atom with face 'j'
- ::
- =/ j=@ 2
- :: Create a trap as the point of recursion which evaluates to a boolean
- ::
- |- ^- ?
- :: If the product of 'i' and 'j' is equal to 'n', evalute to false.
- ::
- ?: =((mul i j) n) |
- :: If 'n' divided by 2 equals 'j', evalute to true
- ::
- ?: =(j (div n 2)) &
- :: Check if the product of 'i' and 'j' is > 'n'
- ::
- ?: (gth (mul i j) n)
- :: If it is, then make a recursive call back to the trap where i is 2 an j is incremented by 1
- ::
- $(i 2, j +(j))
- :: Otherwise, make a recursive call back to the trap where 'i' is incremented by 1
- ::
- $(i +(i))
- :: This defines the second arm in the core with face 'goldbach'
- ::
- ++ goldbach
- :: Define a gate that takes an atom with face 'n' as the argument
- ::
- |= n=@
- :: Cast the gate to the boolean type OR a cell that contains a tuple of atoms and the boolean type
- ::
- ^- ?(? [[@ @] ?])
- :: Evaluate to false if 'n' is < 4 or 'n' is odd
- ::
- ?: |((lth n 4) =((mod n 2) 1)) |
- :: Store the value 2 as an atom with face 'i'
- ::
- =/ i=@ 2
- :: Store the value of 'n' minus 2 as an atom with face 'j'
- ::
- =/ j=@ (sub n 2)
- :: Create a trap that casts to the boolean type OR a cell that contains a tuple of atoms and the boolean type
- ::
- |- ^- ?(? [[@ @] ?])
- :: Check if 'i' and 'j' are prime, and if they are, create a cell with 'i' and 'j' as a tuple and false.
- ::
- ?: &((prime i) (prime j)) [[i j] |]
- :: Otherwise, check if 'i' plus 2 equals 'n'
- ::
- ?: =((add 2 i) n)
- :: If it is, recurse back to the trap with 'i' incremented by 1, and 'j' decremented by 1
- ::
- $(i +(i), j (dec j))
- :: Note the end of the core's arm defintions
- ::
- --
- PART 2
- :: the comment ":: code belongs here" indicates that one or more lines of code are needed to make this section of the program work.
- !:
- |= raw=tape
- =<
- :: code belongs here
- (convert (cuss raw))
- |%
- ++ convert
- :: code belongs here
- |= input=tape
- :: (~(got by a) b) produces the value located at key b within map a
- =/ chart ~(got by table)
- =/ output=tape ""
- |- ^- tape
- :: code belongs here
- ?~ input output
- ?: (~(has by table) i.input)
- =/ token=cord (chart i.input)
- =/ suffix=tape (trip token)
- $(output (weld output suffix), input t.input)
- $(input t.input)
- ++ table
- %- my
- :~ :- 'A' '.-'
- :- 'B' '-...'
- :- 'C' '-.-.'
- :- 'D' '-..'
- :- 'E' '.'
- :- 'F' '..-.'
- :- 'G' '--.'
- :- 'H' '....'
- :- 'I' '..'
- :- 'J' '.---'
- :- 'K' '-.-'
- :- 'L' '.-..'
- :- 'M' '--'
- :- 'N' '-.'
- :- 'O' '---'
- :- 'P' '.--.'
- :- 'Q' '--.-'
- :- 'R' '.-.'
- :- 'S' '...'
- :- 'T' '-'
- :- 'U' '..-'
- :- 'V' '...-'
- :- 'W' '.--'
- :- 'X' '-..-'
- :- 'Y' '-.--'
- :- 'Z' '--..'
- :- '0' '-----'
- :- '1' '.----'
- :- '2' '..---'
- :- '3' '...--'
- :- '4' '....-'
- :- '5' '.....'
- :- '6' '-....'
- :- '7' '--...'
- :- '8' '---..'
- :- '9' '----.'
- :- ' ' ' '
- ==
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement