-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.lisp
More file actions
41 lines (35 loc) · 1.23 KB
/
utils.lisp
File metadata and controls
41 lines (35 loc) · 1.23 KB
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
38
39
40
(in-package :smacklisp)
;; copied from arvid-utils
;; alexandria has similar for sequences
;; stolen from paip
(defun list-of-length-p (l n)
(if (= n 0)
(null l)
(and (consp l)
(list-of-length-p (rest l) (1- n)))))
(defun singlep (l)
(and (consp l) (null (rest l))))
(defun doublep (l)
(and (consp l) (singlep (rest l))))
;; copied from arvid-utils
;; from my own idiot brain
;; maybe should be macro? not likely to map/funcall this.
(defun make-adjustable-string (size &key (element-type 'character)
(initial-element #\Space)
(initial-contents nil initial-contents-p))
"similar to make-string "
(if initial-contents-p
(make-array (list size)
:initial-contents initial-contents
:element-type element-type
:fill-pointer t
:adjustable t)
(make-array (list size)
:initial-element initial-element
:element-type element-type
:fill-pointer t
:adjustable t)))
;; wrapper macro for named-readtables
(defmacro with-named-readtable ((name) &body body)
`(let ((*readtable* (ensure-readtable ,name)))
,@body))