-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathutil.lisp
37 lines (29 loc) · 899 Bytes
/
util.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
(in-package :cqlcl)
(defmacro rev-hash (ht)
(let ((ht-sym (gensym "hash-table"))
(ht-orig (gensym "hash-table-orig"))
(k (gensym))
(v (gensym)))
`(let* ((,ht-orig ,ht)
(,ht-sym (make-hash-table :size (hash-table-count ,ht) :test #'equal)))
(maphash (lambda (,k ,v)
(setf (gethash ,v ,ht-sym) ,k)) ,ht-orig)
,ht-sym)))
(defun make-stream-from-byte-vector (bv)
(flexi-streams:make-flexi-stream
(flexi-streams:make-in-memory-input-stream bv)))
(defun empty? (thing)
(zerop (length thing)))
(defmacro while (condition &rest body)
`(loop while ,condition
do
,@body))
(defun drain-stream (stream)
(let ((out nil))
(while (listen stream)
(push (read-byte stream) out))
(reverse out)))
(defun juxt (&rest funs)
(lambda (v)
(mapcar (lambda (f)
(funcall f v)) funs)))