diff --git a/Writing.org b/Writing.org index 4eb9469..0c5d704 100644 --- a/Writing.org +++ b/Writing.org @@ -103,7 +103,7 @@ After the variable declaration list, the next form is one or more unevaluated tr #+BEGIN_SRC lisp ;; 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 - (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-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 diff --git a/snippets/avas-laptop-prompt.f b/snippets/avas-laptop-prompt.f index a3c9830..94c0247 100644 --- a/snippets/avas-laptop-prompt.f +++ b/snippets/avas-laptop-prompt.f @@ -16,7 +16,7 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . -;; AVA'S LAPTOP PROMPT +;; AVAS LAPTOP PROMPT ;; This file contains a shell prompt configuration that outputs current dir ;; username, and percentages for all batteries on the system. ;; -> requires CFG_FLESH_POSIX=true and userlib. diff --git a/snippets/userlib-tests.f b/snippets/userlib-tests.f index b1b545f..150dc9e 100644 --- a/snippets/userlib-tests.f +++ b/snippets/userlib-tests.f @@ -114,6 +114,12 @@ (add-path 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 )) diff --git a/snippets/userlib.f b/snippets/userlib.f index 650dd66..816684b 100644 --- a/snippets/userlib.f +++ b/snippets/userlib.f @@ -146,3 +146,13 @@ adds a directory to PATH' (rem (cdr path-iter))) (echo pat) (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))