Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: Assignment A
- :: create a gate that accepts an atom and give it the face n
- ::
- |= n=@
- :: evaluate the first child expression with respect to its second child expression as the subject
- ::
- =< (goldbach n)
- |%
- :: define arm with the face prime to check if input atom is a prime number
- ::
- ++ prime
- :: create gate that accepts atom and gives it face of n
- ::
- |= n=@
- :: cast output as flag
- ::
- ^- ?
- :: if n is less than 2 produce %.n (not prime numbers)
- ::
- ?: (lth n 2) |
- :: if n is less than 4 (i.e. 3) produce %.y (3 is prime)
- ::
- ?: (lth n 4) &
- :: if n is less than 4 create two atoms with faces of i and j and initial values of 2
- ::
- =/ i=@ 2
- =/ j=@ 2
- :: create recursion trap that returns loobean when recursion exits
- |- ^- ?
- :: if i x j equals n
- ?: =((mul i j) n) |
- :: or if j equals n divided by 2
- ?: =(j (div n 2)) &
- :: and if i x j is greater than n
- ?: (gth (mul i j) n)
- :: set i to 2 and increment j
- $(i 2, j +(j))
- :: increment i
- $(i +(i))
- :: define arm with the face goldbach
- ::
- ++ goldbach
- :: create a gate that accepts an atom with the face n
- |= n=@
- :: cast output to loobean or cell encapsulating a cell of two atoms and a loobean
- ^- ?(? [[@ @] ?])
- :: if n is less than 4 or n modulo 2 remainder is 1
- ?: |((lth n 4) =((mod n 2) 1)) |
- :: create atom with face i and initial value of 2
- =/ i=@ 2
- :: create atom with face j and initial value of n - 2
- =/ j=@ (sub n 2)
- :: create trap that casts output to loobean or cell encapsulating a cell of two atoms and a loobean
- |- ^- ?(? [[@ @] ?])
- :: if i and j are prime numbers return cell encapsulating cell of i and j and produce %.n
- ?: &((prime i) (prime j)) [[i j] |]
- :: if addition of 2 and i equals n produce %.y
- ?: =((add 2 i) n) &
- :: recurse incrementing i and decrementing j
- $(i +(i), j (dec j))
- :: close core
- --
- :: Assignment B
- :: Convert message into morse code
- |= raw=tape
- =< (convert (cuss raw))
- |%
- ++ convert
- |= message=tape
- ^- tape
- =| morse=tape
- |-
- ?~ message morse
- =/ chart (~(got by table) i.message)
- $(message t.message, morse (weld morse (trip chart)))
- ++ 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