diff --git a/test/test-core.lisp b/test/test-core.lisp index 56c9bcb..b0e550c 100644 --- a/test/test-core.lisp +++ b/test/test-core.lisp @@ -67,6 +67,10 @@ (util:lgi (crypt:create-secret)) (let ((now (get-universal-time))) (== (util:from-unix-time (util:to-unix-time now)) now)) + (let* ((x (util:ptr)) + (y x)) + (setf (aref y) 42) + (== (aref x) 42)) (== (util:rfill '(1 2 3 4 5) '(a b c)) '(a b c nil nil)) (== (util:rtrim '(1 2 nil 3 nil)) '(1 2 nil 3)) (== (util:to-keyword "hello-kitty") :hello-kitty) diff --git a/util/util.lisp b/util/util.lisp index 747956d..95ad263 100644 --- a/util/util.lisp +++ b/util/util.lisp @@ -6,6 +6,7 @@ #+sbcl (:import-from :sb-ext #:add-package-local-nickname) (:export #:make-vars-format #:lg #:lgd #:lgi #:lgw #:from-unix-time #:to-unix-time + #:ptr #:rfill #:rtrim #:loop-plist #:filter-plist #:plist-pairs #:plist-equal #:plist-add #:flatten-str #:from-keyword #:to-keyword #:to-integer #:to-string @@ -41,7 +42,10 @@ (defun to-unix-time (time) (when time (- time +unix-time-base+))) -;;;; lists and loops +;;;; pointers, lists, loops + +(defun ptr (&optional x) + (make-array nil :initial-element x)) (defun rfill (ll ls) (mapcar #'(lambda (x) (pop ls)) ll))