by konjin · 5y ago · 0 comments
Even the readme says as much: The syntax of wax is inspired by WebAssembly Text Format (wat), hence the name. Though it uses S-expressions reminiscent of the Lisp family, it is actually quite imperative and most resemblant of C in its design. The idea of transpiling to many languages is inspired by Haxe.
This is actual standard Common Lisp and basically the same (minus slightly different syntax) as the quicksort example from the link:
(defun qksort-inplace (a lo hi)
(declare (type integer lo hi)
(type (array float) a))
(if (>= lo hi)
(return-from qksort-inplace))
(let ((pivot (aref a lo))
(left lo)
(right hi))
(declare (type float pivot)
(type integer lo hi))
(loop while (<= left right) do
(loop while (< (aref a left) pivot) do
(setf left (+ left 1)))
(loop while (> (aref a right) pivot) do
(setf right (- right 1)))
(if (<= left right)
(let ((tmp (aref a left)))
(setf (aref a left) (aref A right)
(aref a right) tmp
left (+ left 1)
right (- right 1)))))
(qksort-inplace A lo right)
(qksort-inplace A left hi)))