Add optional, variadic arguments
diff --git a/lib/lisp/std/std.lisp b/lib/lisp/std/std.lisp
index 096b885..388637b 100644
--- a/lib/lisp/std/std.lisp
+++ b/lib/lisp/std/std.lisp
@@ -1,5 +1,7 @@
;;;; std.lisp -- Lisp standard library
+;; Boring utilities
+
(defun caar (val)
(car (car val)))
@@ -15,12 +17,32 @@
(defun caddar (val)
(car (cdr (cdr (car val)))))
+;; /Boring utilitites
+
+
+
;; Instead of a function this is a macro for a slight performance increase
(defmacro not (val)
(nilp val))
;; TODO: make tail recursive (for this `flet` would be nice)
(defun length (list)
+ "Returns the length of `list`, or `nil` if it is not a list"
(if (nilp list)
0
(+ 1 (length (cdr list)))))
+
+(defmacro when (cond & body)
+ "Evaluate `body` when `cond` is truthy.
+When `cond` is truthy, evaluates `body` in order, finally evaluating to
+the final item."
+ (list 'if cond
+ (cons 'progn body)))
+
+(defmacro unless (cond & body)
+ "Evaluate `body` unless `cond` is truthy.
+When `cond` is nil, evaluates `body` in order, finally evaluating to the
+final item."
+ (list 'if cond
+ nil
+ (cons 'progn body)))