|
55 | 55 |
|
56 | 56 | (defun str-to-ascii-int:integer (in:string) |
57 | 57 | "Convert a string to its integer ASCII representation" |
58 | | - (let ((shift-add (lambda (x y) (+ (shift x 8) y)))) |
59 | | - (fold (shift-add) 0 (decode-ascii in))) |
| 58 | + (fold (lambda (x y) (+ (shift x 8) y)) 0 (decode-ascii in)) |
60 | 59 | ) |
61 | 60 |
|
62 | 61 | (defun encode-ascii:string (in-list:[integer]) |
|
72 | 71 | (if (!= in 0) |
73 | 72 | (let ((len (ceiling (log 256.0 (dec in)))) |
74 | 73 | (extract-char-value (lambda (idx) (mod (shift in (* -8 idx)) 256)))) |
75 | | - (encode-ascii (map (extract-char-value) (enumerate (- len 1) 0)))) |
| 74 | + (encode-ascii (map extract-char-value (enumerate (- len 1) 0)))) |
76 | 75 | "") |
77 | 76 | ) |
78 | 77 |
|
|
100 | 99 | "Returns true if in contains one of the characters in values" |
101 | 100 | (let ((values-lists (str-to-list values)) |
102 | 101 | (contains-char (lambda (x) (contains x in)))) |
103 | | - (fold (or) false (map (contains-char) values-lists))) |
| 102 | + (fold (or) false (map contains-char values-lists))) |
104 | 103 | ) |
105 | 104 |
|
106 | 105 | (defun replace-char:string (in:string old-char:string new-char:string) |
|
114 | 113 | (if (and? (<= 97) (>= 122) x) |
115 | 114 | (- x 32) |
116 | 115 | x)))) |
117 | | - (encode-ascii (map (do-upper) (decode-ascii in)))) |
| 116 | + (encode-ascii (map do-upper (decode-ascii in)))) |
118 | 117 | ) |
119 | 118 |
|
120 | 119 | (defun lower:string (in:string) |
|
123 | 122 | (if (and? (<= 65) (>= 90) x) |
124 | 123 | (+ x 32) |
125 | 124 | x)))) |
126 | | - (encode-ascii (map (do-lower) (decode-ascii in)))) |
| 125 | + (encode-ascii (map do-lower (decode-ascii in)))) |
127 | 126 | ) |
128 | 127 |
|
129 | 128 | (defun char-at:string (idx:integer in:string) |
|
151 | 150 | [] ;If the string is empty return a zero length list |
152 | 151 | (let ((sep-pos (search (str-to-list in) separator)) |
153 | 152 | (substart (map (+ 1) (insert-first sep-pos -1))) |
154 | | - (sublen (zip (-) (append-last sep-pos 10000000) substart)) |
| 153 | + (sublen (zip - (append-last sep-pos 10000000) substart)) |
155 | 154 | (cut (lambda (start len) (take len (drop start in))))) |
156 | | - (zip (cut) substart sublen))) |
| 155 | + (zip cut substart sublen))) |
157 | 156 | ) |
158 | 157 |
|
159 | 158 | (defun split-chunks:[string] (chunk-size:integer in:string) |
|
164 | 163 | (take-chunk (lambda (x) (take chunk-size (drop (* x chunk-size) in))))) |
165 | 164 | (if (= 0 out-len) |
166 | 165 | [] |
167 | | - (map (take-chunk) (enumerate 0 (- out-len 1))))) |
| 166 | + (map take-chunk (enumerate 0 (- out-len 1))))) |
168 | 167 | ) |
169 | 168 |
|
170 | 169 | (defun starts-with:bool (in:string to-match:string) |
|
0 commit comments