-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtmu.cl
More file actions
86 lines (71 loc) · 2.33 KB
/
tmu.cl
File metadata and controls
86 lines (71 loc) · 2.33 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
;playing w/some xml 2json files, bobak
;;had (lu) but now: (lkm3)
(ql 'xmls)
(defun parse-xmlsfile (filename &key (output-type nil))
"might have better output than s-xml"
(when output-type (warn "this is xmls not s-xml"))
(with-open-file (in filename :direction :input)
(xmls:parse in)))
(defvar *ix* (parse-xmlsfile "index.xml"))
(ql 's-xml)
(defvar *i-x* (s-xml:parse-xml-file "index.xml"))
(defun save-l (l filename)
(when (fulll l)
(with-open-file (strm filename :direction :output)
;(write l strm)
(format strm "~%~a~%" l)
)))
(defun save-s (s filename)
(with-open-file (strm filename :direction :output)
(format strm "~%~a~%" s)
))
(defun len0 (l)
(if (listp l) (length l)
0))
(defun restn (l n)
(if (or (null l) (eq n 0)) l
(restn (rest l) (1- n))))
(defun depth-gt (l n)
(> (tree_depth l) n))
(defun depth-gt2 (l &optional (n 2))
(depth-gt l n))
(defun first-lvv (l)
"just ret a single Val"
(let ((lv (first-lv l)))
(if (listp lv) (first-lvv lv)
lv)))
(defun second-lvv (l)
"just ret a single Val"
(let ((lv (second-lv l)))
(if (listp lv) (second-lvv lv)
lv)))
#+ignore
(defun save-lines (l filename)
(when (fulll l)
(with-open-file (stream filename :direction :output)
(mapcar #'(lambda (x) (write-line x stream)) l))))
(defun rwl (r wx)
(mapcar #'(lambda (a) (if (listp a) (rwl a wx) ;
(funcall wx a))) r)) ;only print vals not lists
(defun saverlines (l filename)
(when (fulll l)
(with-open-file (stream filename :direction :output)
(flet ((wx (p) (write-line p stream)))
;;(wl (r) (mapcar #'wx r))
;(wl (r) (mapcar #'(lambda (a) (if (listp a) (wl a) (wx a))) r)) (wl l)
(rwl l #'wx)
))))
(require :cl-json)
(defun encode-json2str (js)
(if (equal js '(nil)) "[]"
(json:encode-json-to-string js)))
(defun save-js (js filename)
(save-s (encode-json2str js) filename))
;also looked at xml2json xmlstarlet xsltproc xml2json-xslt jq underscore jsonpp ppjson
; then-get some output already csv or similar, w/some sed (for extra slashes)
;(defun csv-bar (l) (csv_parse-str l :separator #\|))
(defun csv-slash (l) (csv_parse-str l :separator #\/))
(defun prs-slash-file (fn) (mapcar #'csv-slash (list-lines fn)))
(defun t1 () (prs-slash-file "af/a1.txt"))
(defvar *t1* (t1))
;can: (mapcar #'len *t1*)