Browse code

Cleaning up bloat, etc.

Jaidyn Lev authored on 2019-01-07 01:51:31
Showing 3 changed files
... ...
@@ -1,65 +1,5 @@
1 1
 (in-package :nih)
2 2
 
3
-;; ITEM LIST --> DATA_AFTER_ITEM
4
-(defun following (item list &key (test #'eq))
5
-  "Return all items following the first instance of ITEM"
6
-
7
-  (cdr (up-from (position item list :test test) list)))
8
-
9
-
10
-;; ITEM LIST --> DATA_UP_TO_ITEM
11
-(defun preceding (item list &key (test #'eq))
12
-  "Return all items preceding the first instance of ITEM"
13
-
14
-  (reverse
15
-    (cdr (reverse
16
-	   (up-to (position item list :test test) list)))))
17
-
18
-
19
-;; ----------------------------------------
20
-
21
-
22
-;; ITEM LIST --> ITEM_BEFORE_ITEM
23
-(defun before (item list)
24
-  "Return the single item before ITEM"
25
-
26
-  (car (reverse (preceding item list))))
27
-
28
-
29
-;; ITEM LIST --> ITEM_AFTER_ITEM
30
-(defun after (item list)
31
-  "Return the single item after ITEM"
32
-
33
-  (car (following item list)))
34
-
35
-
36
-;; ----------------------------------------
37
-
38
-
39
-;; N LIST --> LIST_FROM_N
40
-(defun up-from (n list &optional (n-stack 0))
41
-  "Return all items after and including the position N in list"
42
-
43
-  (if (eq n n-stack)
44
-    list
45
-    (up-from n (cdr list) (+ n-stack 1))))
46
-
47
-
48
-;; N LIST --> LIST_UP_TO_N
49
-(defun up-to (n list &optional (n-stack 0))
50
-  "Return all items before and including the position N in list"
51
-
52
-  (cond
53
-    ((not (car list)) nil)
54
-    ((eq n n-stack) (list (car list)))
55
-    ((concatenate 'list
56
-		  (list (car list))
57
-		  (up-to n (cdr list) (+ n-stack 1))))))
58
-
59
-
60
-;; ----------------------------------------
61
-
62
-
63 3
 ;; ITEM LIST --> LIST_OF_ITEM_POS
64 4
 (defun positions (item list &key (test #'eq))
65 5
   "Return a list of positions of an item in a list."
... ...
@@ -46,12 +46,12 @@
46 46
 
47 47
 
48 48
 ;; LIST --> RANDOM_ITEM
49
-(defun random-item (list)
49
+(defun random-item (&rest list)
50 50
   "Return a random item from a list."
51 51
 
52 52
   (if (not list)
53 53
     nil
54
-    (nth (random (length list)) list)))
54
+    (nth (random (length (list-or-real list))) (list-or-real list))))
55 55
 
56 56
 ;; INTEGER LIST --> LIST
57 57
 (defun random-items (number list)
... ...
@@ -64,23 +64,3 @@
64 64
 		   (list item)
65 65
 		   (if (not (eq number 1))
66 66
 		     (random-items (- number 1) (remove item list)))))))
67
-
68
-;; FILE_PATH --> BOOLEAN
69
-(defun file-exists (path)
70
-  "Return whether or not a file exists."
71
-
72
-  (if (ignore-errors (file-author path))
73
-    'T
74
-    nil))
75
-
76
-
77
-;; STREAM --> STRING_OF_ENTIRE_STREAM
78
-(defun read-line-entire (stream)
79
-  (let* ((cur-line (ignore-errors (read-line stream))))
80
-
81
-    (cond
82
-      (cur-line
83
-	(string-combine cur-line
84
-			(read-line-entire stream)
85
-			:seperator (format nil "~%")) )
86
-      ('T ""))))
... ...
@@ -24,7 +24,7 @@
24 24
   me want to eat my fucking hat. >;c"
25 25
 
26 26
   (multiple-value-bind (keys strings)
27
-    (parse-keys arg-list '(:seperator))
27
+    (parse-keys (list-or-real arg-list) '(:seperator))
28 28
 
29 29
     (let ((seperator (value-or (getf keys :seperator) "")))
30 30
 
... ...
@@ -32,6 +32,9 @@
32 32
 		(format nil "~A~A~A" word1 seperator word2))
33 33
 	      strings))))
34 34
 
35
+(defun string+ (&rest arg-list)
36
+  (string-combine arg-list))
37
+
35 38
 
36 39
 ;; STRING_A STRING_B --> SYMBOL_OF_STRING_A+STRING_B
37 40
 (defun intern-combine (&rest arg-list)