GitHub - raoofha/pr: a single character turns a universal primitive recursive function into a universal general recursive function · GitHub
/" data-turbo-transient="true" />
Skip to content
Search or jump to...
Search code, repositories, users, issues, pull requests...
-->
Search
Clear
Search syntax tips
Provide feedback
--><br>We read every piece of feedback, and take your input very seriously.
Include my email address so I can be contacted
Cancel
Submit feedback
Saved searches
Use saved searches to filter your results more quickly
-->
Name
Query
To see all available qualifiers, see our documentation.
Cancel
Create saved search
Sign in
/;ref_cta:Sign up;ref_loc:header logged out"}"<br>Sign up
Appearance settings
Resetting focus
You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.
Dismiss alert
{{ message }}
raoofha
pr
Public
Notifications<br>You must be signed in to change notification settings
Fork
Star
main
BranchesTags
Go to file
CodeOpen more actions menu
Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit
History<br>3 Commits<br>3 Commits
README.md
README.md
gate.hs
gate.hs
pr.hs
pr.hs
View all files
Repository files navigation
a single character change a universal primitive recursive function into a universal general recursive function
an implementation of LOOP programming language as a list of pairs of natural numbers
0 0 -- noop
r 0 -- inc r
0 r -- dec r
r p -- repeat program number p r times
[(Natural,Natural)] -> [Natural] -> [Natural]<br>_pr i p rs =<br>if i _pr 0 q rs) rs)!!(fromIntegral vop1))<br>else if op1==0 && op2==0 then rs<br>else if op2==0 then _pr (i+1) p (listSet rs _op1 (vop1 +1))<br>else _pr (i+1) p (listSet rs _op2 (if vop2>0 then vop2-1 else 0))<br>else rs
pr rs =<br>case (map cantorUnpair (cantorUnpairAll (listGet rs 0 0))) of<br>[]-> listGet (_pr 0 [(0,0)] (tail rs)) 0 0<br>q -> listGet (_pr 0 q (tail rs)) 0 0">_pr :: Natural -> [(Natural,Natural)] -> [Natural] -> [Natural]<br>_pr i p rs =<br>if i (fromIntegral (length p)) then<br>let<br>(op1,op2) = (p!!(fromIntegral i))<br>_op1 = (fromIntegral (op1-1))<br>_op2 = (fromIntegral (op2-1))<br>_i = (fromIntegral i)<br>vop1 = (listGet rs _op1 0)<br>vop2 = (listGet rs _op2 0)<br>in<br>if op1 /= 0 && op2 /= 0 then<br>let q = (map cantorUnpair (cantorUnpairAll op2)) -- changing op2 to vop2 enable self-reference and pr becomes a universal general recursive function<br>in _pr (i+1) p ((iterate (\rs -> _pr 0 q rs) rs)!!(fromIntegral vop1))<br>else if op1==0 && op2==0 then rs<br>else if op2==0 then _pr (i+1) p (listSet rs _op1 (vop1 +1))<br>else _pr (i+1) p (listSet rs _op2 (if vop2>0 then vop2-1 else 0))<br>else rs
pr rs =<br>case (map cantorUnpair (cantorUnpairAll (listGet rs 0 0))) of<br>[]-> listGet (_pr 0 [(0,0)] (tail rs)) 0 0<br>q -> listGet (_pr 0 q (tail rs)) 0 0
About<br>a single character turns a universal primitive recursive function into a universal general recursive function<br>Resources<br>Readme<br>Activity<br>Stars<br>0 stars<br>Watchers<br>0 watching<br>Forks<br>0 forks<br>Report repository
Releases
Packages
Contributors
Languages
You can’t perform that action at this time.