1 (uiop:define-package
#:lw2.utils
3 (:export
#:alist
#:get-unix-time
#:substring
#:to-boolean
#:map-plist
)
4 (:recycle
#:lw2-viewer
))
6 (in-package #:lw2.utils
)
8 (declaim (inline alist
))
9 (defun alist (&rest parms
) (alexandria:plist-alist parms
))
11 (defun get-unix-time ()
12 (- (get-universal-time) #.
(encode-universal-time 0 0 0 1 1 1970 0)))
14 (deftype array-dimension-type
() `(integer 0 ,(- array-dimension-limit
1)))
16 (declaim (inline substring
)
17 (ftype (function (string array-dimension-type
&optional array-dimension-type
) string
) substring
))
18 (defun substring (string start
&optional
(end (length string
)))
19 (make-array (- end start
) :element-type
'character
:displaced-to string
:displaced-index-offset start
))
21 (declaim (inline to-boolean
))
22 (defun to-boolean (value)
25 (defun map-plist (fn plist
)
26 (loop for
(key val . rest
) = plist then rest
28 nconc
(funcall fn key val
)))