stdlib dir created
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
; quicksort
|
; quicksort
|
||||||
(defun qs (l)
|
(defun quick-sort (l)
|
||||||
(if (<= (len l) 1)
|
(if (<= (len l) 1)
|
||||||
l
|
l
|
||||||
(do
|
(do
|
||||||
@@ -13,8 +13,10 @@
|
|||||||
|
|
||||||
; decrement a number
|
; decrement a number
|
||||||
(defun dec (n) (- n 1))
|
(defun dec (n) (- n 1))
|
||||||
|
|
||||||
; increment a number
|
; increment a number
|
||||||
(defun inc (n) (+ n 1))
|
(defun inc (n) (+ n 1))
|
||||||
|
|
||||||
; not a bool
|
; not a bool
|
||||||
(defun not (x) (if x 0 1))
|
(defun not (x) (if x 0 1))
|
||||||
|
|
||||||
@@ -23,12 +25,8 @@
|
|||||||
|
|
||||||
; is a number positive?
|
; is a number positive?
|
||||||
(defun is-pos? (n) (> n 0))
|
(defun is-pos? (n) (> n 0))
|
||||||
|
|
||||||
; is a number negative?
|
; is a number negative?
|
||||||
(defun is-neg? (n) (< n 0))
|
(defun is-neg? (n) (< n 0))
|
||||||
|
|
||||||
; define a function `fact` that takes an argument `n`
|
|
||||||
(defun fact (n)
|
|
||||||
(if (<= n 1)
|
|
||||||
1
|
|
||||||
(* n (fact (- n 1)))
|
|
||||||
))
|
|
||||||
Reference in New Issue
Block a user