Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Creates a gate that takes any atom, called n
- ::
- |= n=@
- :: Runs the goldbach arm with n as the subject
- ::
- =< (goldbach n)
- :: Declares a new core,
- ::
- |%
- :: with an arm called prime.
- ::
- ++ prime
- :: prime contains a gate that takes any atom and calls it n
- :: it determines if n is a prime number or not.
- ::
- |= n=@
- :: Casts the gate's result to a flag
- ::
- ^- ?
- :: If n is less than 2 then this evaluates to no
- ::
- ?: (lth n 2) |
- :: if n is less than 2 then yes
- ::
- ?: (lth n 4) &
- :: Adds 2 to the subject as i
- ::
- =/ i=@ 2
- :: Adds 2 to the subject as j
- ::
- =/ j=@ 2
- :: Creates a trap that typecasts to a flag
- ::
- |- ^- ?
- :: if i times j euqals n then no
- ::
- ?: =((mul i j) n) |
- :: and if j equals n divided by 2 then yes
- ::
- ?: =(j (div n 2)) &
- :: is i times j greater than n?
- ::
- ?: (gth (mul i j) n)
- :: If so, then recurse with i set to 2 and j incremented
- ::
- $(i 2, j +(j))
- :: if not, then recurse with i incremented
- $(i +(i))
- :: this is an arm called goldbach.
- ::
- ++ goldbach
- :: it has a gate that takes n, an atom
- ::
- |= n=@
- :: Typecasts the result to either a flag or a cell containing two atoms and a flag
- ::
- ^- ?(? [[@ @] ?])
- :: if n is less than 4 or n divided by 2 has a remainder of 1,
- :: return a no flag as n isn't covered under the goldbach conjecture
- ::
- ?: |((lth n 4) =((mod n 2) 1)) |
- :: the subject now includes i, an atom with the value of 2,
- ::
- =/ i=@ 2
- :: as well as j, the value of n minus 2
- ::
- =/ j=@ (sub n 2)
- :: A trap that typecasts to either a flag or a cell containing two atoms and a flag
- ::
- |- ^- ?(? [[@ @] ?])
- :: if i and j are prime then [[i j] no]
- :: [[i j] n] are the prime numbers that add up to n.
- :: no is added because the goldbach conjecture wasn't disproven
- ::
- ?: &((prime i) (prime j)) [[i j] |]
- :: if this isn't true then check to see if i + 2 = n
- :: if true then the goldbach conjecture was disproven, return yes
- ::
- ?: =((add 2 i) n) &
- :: if this isn't false, then recurse; incrememting i and decrememting j
- ::
- $(i +(i), j (dec j))
- --
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement