Add or fix docstrings of syscalls.
[iolib.git] / base / sequence.lisp
blobd08280d254f008421ca7669cf2b369d4c788d34e
1 ;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; indent-tabs-mode: nil -*-
2 ;;;
3 ;;; --- Sequence utils
4 ;;;
6 (in-package :iolib.base)
8 (defmacro check-bounds (sequence start end)
9 (with-gensyms (length)
10 `(let ((,length (length ,sequence)))
11 (check-type ,start unsigned-byte "a non-negative integer")
12 (when ,end (check-type ,end unsigned-byte "a non-negative integer or NIL"))
13 (unless ,end
14 (setf ,end ,length))
15 (unless (<= ,start ,end ,length)
16 (error "Wrong sequence bounds. start: ~S end: ~S" ,start ,end)))))
18 (defun join (connector &rest strings)
19 (let ((c (string connector)))
20 (concatenate 'string (car strings)
21 (reduce (lambda (str1 str2)
22 (concatenate 'string str1 c str2))
23 (cdr strings)
24 :initial-value ""))))