add join function to stdlib
Signed-off-by: Ava Affine <ava@sunnypup.io>
This commit is contained in:
parent
386d0900a9
commit
3d0d8d8215
4 changed files with 18 additions and 2 deletions
|
|
@ -103,7 +103,7 @@ After the variable declaration list, the next form is one or more unevaluated tr
|
||||||
#+BEGIN_SRC lisp
|
#+BEGIN_SRC lisp
|
||||||
;; Example let statement accepts one incoming connection on a socket and sends one response
|
;; Example let statement accepts one incoming connection on a socket and sends one response
|
||||||
(let ((conn (accept-conn listen-socket)) ;; start the var decl list, decl first var
|
(let ((conn (accept-conn listen-socket)) ;; start the var decl list, decl first var
|
||||||
(hello-pfx "hello from ") ;; start the var decl list, declare second var
|
(hello-pfx "hello from ") ;; declare second var
|
||||||
(hello-msg (concat hello-pfx (get-server-name))) ;; declare third var from the second var
|
(hello-msg (concat hello-pfx (get-server-name))) ;; declare third var from the second var
|
||||||
(hello-response (make-http-response 200 hello-msg))) ;; declare fourth var from the third, end list
|
(hello-response (make-http-response 200 hello-msg))) ;; declare fourth var from the third, end list
|
||||||
(log (concat "response to " (get-dst conn) ": " hello-msg)) ;; evaluates a function call using data from the first and third vars
|
(log (concat "response to " (get-dst conn) ": " hello-msg)) ;; evaluates a function call using data from the first and third vars
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
;; You should have received a copy of the GNU General Public License
|
;; You should have received a copy of the GNU General Public License
|
||||||
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
;; AVA'S LAPTOP PROMPT
|
;; AVAS LAPTOP PROMPT
|
||||||
;; This file contains a shell prompt configuration that outputs current dir
|
;; This file contains a shell prompt configuration that outputs current dir
|
||||||
;; username, and percentages for all batteries on the system.
|
;; username, and percentages for all batteries on the system.
|
||||||
;; -> requires CFG_FLESH_POSIX=true and userlib.
|
;; -> requires CFG_FLESH_POSIX=true and userlib.
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,12 @@
|
||||||
(add-path new-path)
|
(add-path new-path)
|
||||||
(contains? (get-paths) new-path))))
|
(contains? (get-paths) new-path))))
|
||||||
|
|
||||||
|
('join operates as expected'
|
||||||
|
(quote
|
||||||
|
(let ((l ("1" 2 (3))))
|
||||||
|
(eq? (join l ".")
|
||||||
|
"1.2.(3)"))))
|
||||||
|
|
||||||
;; add more test cases here
|
;; add more test cases here
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,3 +146,13 @@ adds a directory to PATH'
|
||||||
(rem (cdr path-iter)))
|
(rem (cdr path-iter)))
|
||||||
(echo pat)
|
(echo pat)
|
||||||
(set (q path-iter) (pop rem))))))
|
(set (q path-iter) (pop rem))))))
|
||||||
|
|
||||||
|
(def join
|
||||||
|
'concatenates list elements into a string, while
|
||||||
|
interspersing a provided delimiter in between elements'
|
||||||
|
(list delim)
|
||||||
|
(reduce (lambda (res elem)
|
||||||
|
(if (eq? (strlen res) 0)
|
||||||
|
(string elem)
|
||||||
|
(concat res delim elem)))
|
||||||
|
list))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue