Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: week 5a
- :: ~figrum-lonlug
- ::
- :: create a gate with atom sample
- ::
- |= n=@
- ::
- :: execute 'goldbach' arm passing sample in
- :: but first, add the core below to the subject
- ::
- =< (goldbach n)
- |%
- ++ prime
- :: take an atom, return a flag
- ::
- |= n=@
- ^- ?
- ::
- :: some edge cases:
- :: <2, not prime
- :: >=2 and <4, prime
- ::
- ?: (lth n 2) |
- ?: (lth n 4) &
- ::
- :: add two atoms to the subject
- :: 'i' lower order factor
- :: 'j' higher order factor
- ::
- =/ i=@ 2
- =/ j=@ 2
- ::
- :: recurse to here
- ::
- |- ^- ?
- ::
- :: if the factors produce 'n',
- :: then n cannot be prime
- ::
- ?: =((mul i j) n) |
- ::
- :: if 'j' has reached half the value
- :: of 'n' then we have exhausted every
- :: possible pair of factors and the
- :: 'n' is prime
- ::
- ?: =(j (div n 2)) &
- ::
- :: if the current pair of factors have
- :: overshot 'n' reset 'i' (the lower order factor)
- :: and increment 'j' (the higher order one)
- ::
- ?: (gth (mul i j) n)
- $(i 2, j +(j))
- ::
- :: otherwise, just increment by one
- ::
- $(i +(i))
- ++ goldbach
- :: declare a gate with atom sample
- ::
- |= n=@
- ::
- :: return type is a union, it can be:
- :: 1. a flag
- :: OR
- :: 2. a cell with:
- :: head: cell of atoms
- :: tail: flag
- ::
- ^- ?(? [[@ @] ?])
- ::
- :: if the input is <4 or odd then it is not a valid
- :: objection
- ::
- ?: |((lth n 4) =((mod n 2) 1)) |
- ::
- :: add two atoms to the subject
- :: summed, these values are always
- :: equal to 'n'
- ::
- =/ i=@ 2
- =/ j=@ (sub n 2)
- ::
- :: recurse to here
- ::
- |- ^- ?(? [[@ @] ?])
- ::
- :: if the two addends are prime, the conjecture stands
- ::
- ?: &((prime i) (prime j)) [[i j] |]
- ::
- :: if 'i' has reached its maximum, we have a true
- :: objection
- ::
- ?: =((add 2 i) n) &
- ::
- :: otherwise try new values, ensuring they still sum to the same
- :: value, 'n'
- ::
- :: week 5b
- :: ~figrum-lonlug
- ::
- |= raw=tape
- ^- tape
- =<
- :: promote all the sub tapes into a single tape
- ::
- %- zing
- ::
- :: place a tape of 2 spaces between each signal
- ::
- %+ join " "
- ::
- :: give input to convert in uppercase
- ::
- (convert (cuss raw))
- ::
- |%
- ++ convert
- |= t=tape
- |- ^- (list tape)
- ?~ t
- ~
- :-
- :: make tape
- ::
- %- trip
- ::
- :: provide a legible default
- :: for unhandled characters
- ::
- %+ fall
- (~(get by table) i.t)
- '?'
- $(t t.t)
- ++ 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