This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;; nock.lisp - The Interpretation and Compilation of Nock Programs. | |
;; | |
;; Nock is the Maxwell's Equations of Software. It is a language that | |
;; powers the Urbit virtual machine; its specification can fit on a | |
;; t-shirt[1]. | |
;; | |
;; In this set of Common Lisp functions below are 'tar', | |
;; a Nock interpreter, 'dao', a Nock compiler and 'phi', | |
;; a Nock compiler driver. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; A nock interpreter | |
(defun tar (a f) | |
(labels ((fas (b a) | |
(declare (integer b)) | |
(cond | |
((= b 1) a) | |
((= b 2) (car a)) | |
((= b 3) (cdr a)) | |
((evenp b) (car (fas (/ b 2) a))) | |
((oddp b) (cdr (fas (/ (1- (the integer b)) 2) a)))))) |