utilities - A collection of utility libraries

A collection of smallish utility libraries.

In case of any inaccuracies, ambiguities or suggestions, please create an issue here.


PARSE-NUMBER

Version: 1.7
Licence: BSD 3-Clause
Repository: sharplispers/parse-number - Github

PARSE-NUMBER is a library of functions which accept an arbitrary string and attempt to parse it, if possible into one of the standard Common Lisp number types without using the reader, or else signal an error of type invalid-number.

invalid-number

Condition

invalid-number-reason

Generic Function: (invalid-number-reason condition)

invalid-number-value

Generic Function: (invalid-number-value condition)

parse-number

Function: (parse-number string &key (start 0) (end NIL) (radix 10)
            ((:float-format *read-default-float-format*)
             *read-default-float-format*))

parse-positive-real-number

Function: (parse-positive-real-number string &key (start 0) (end NIL)
            (radix 10)
            ((float-format *read-default-float-format*)
             *read-default-float-format*))

parse-real-number

Function: (parse-real-number string &key (start 0) (end NIL) (radix 10)
            ((float-format *read-default-float-format*)
             *read-default-float-format*))

SPLIT-SEQUENCE

Version: 2.0.0
Licence: MIT
Repository: sharplispers/split-sequence

split-sequence

Function: (split-sequence delimiter sequence &key (start 0) (end NIL)
           (from-end NIL) (count NIL) (remove-empty-subseqs NIL)
           (test (function eql) test-p) (test-not NIL test-not-p)
           (key (function identity)))

Return a list of subsequences in seq delimited by delimiter. If :remove-empty-subseqs is NIL, empty subsequences will be included in the result; otherwise they will be discarded. All other keywords work analogously to those for cl:substitute. In particular, the behaviour of :from-end is possibly different from other versions of this function; :from-end values of NIL and T are equivalent unless :count is supplied. :count limits the number of subseqs in the main resulting list. The second return value is an index suitable as an argument to cl:subseq into the sequence indicating where processing stopped.

split-sequence-if

Function: (split-sequence-if predicate sequence &key (start 0) (end NIL)
           (from-end NIL) (count NIL) (remove-empty-subseqs NIL)
           (key (function identity)))

Return a list of subsequences in seq delimited by items satisfying predicate. If :remove-empty-subseqs is NIL, empty subsequences will be included in the result; otherwise they will be discarded. All other keywords work analogously to those for cl:substitute-if. In particular, the behaviour of :from-end is possibly different from other versions of this function; :from-end values of NIL and T are equivalent unless :count is supplied. :count limits the number of subseqs in the main resulting list. The second return value is an index suitable as an argument to cl:subseq into the sequence indicating where processing stopped.

split-sequence-if-not

Function: (split-sequence-if-not predicate sequence &key (start 0) (end NIL)
           (from-end NIL) (count NIL) (remove-empty-subseqs NIL)
           (key (function identity)))

Return a list of subsequences in seq delimited by items satisfying (cl:complement predicate). If :remove-empty-subseqs is NIL, empty subsequences will be included in the result; otherwise they will be discarded. All other keywords work analogously to those for cl:substitute-if-not. In particular, the behaviour of :from-end is possibly different from other versions of this function; :from-end values of NIL and T are equivalent unless :count is supplied. :count limits the number of subseqs in the main resulting list. The second return value is an index suitable as an argument to cl:subseq into the sequence indicating where processing stopped.

TRIVIAL-TYPES

Version: 0.1
Licence: LLGPL
Repository: m2ym/trivial-types - Github

TODO: This repository is archived; quickdocs points to this; a branch of a fork is ahead of this.

TRIVIAL-TYPES provides missing but important type definitions such as proper-list, association-list, property-list and tuple.

By using these types, you can keep type declarations more accurate. For example, you may write a class definition like:

(defclass person ()
  ((name :type string))
  ((age :type fixnum))
  ((friends :type list)))

However, it is not obvious for anyone except you that FRIENDS slot has only a list of person. If you want declare friends slot more accurately,proper-list is the best for that:

(defclass person ()
  ((name :type string))
  ((age :type fixnum))
  ((friends :type (proper-list person))))

In addition, TRIVIAL-TYPES also provides standard designators defined in ANSI standard such as package-designator. They are useful when you write a function that takes a package-oid argument like:

(defun list-external-symbols (package)
  (declare (package-designator package))
  (loop for symbol being the external-symbol of package
     collect symbol))

An exhaustive list of provided types includes:

association-list-p

Function: (association-list-p var)

Returns true if OBJECT is an association list.

Examples:

(association-list-p 1) => NIL
(association-list-p '(1 2 3)) => NIL
(association-list-p nil) => T
(association-list-p '((foo))) => T
(association-list-p '((:a . 1) (:b . 2))) => T

file-associated-stream-p

Function: (file-associated-stream-p stream)

Returns true if stream is a stream associated to a file.

proper-list-p

Function: (proper-list-p object)

Returns true if object is a proper list.

Examples:

(proper-list-p 1) => NIL
(proper-list-p '(1 . 2)) => NIL
(proper-list-p nil) => T
(proper-list-p '(1 2 3)) => T

property-list-p

Function: (property-list-p object)

Returns true if object is a property list.

Examples:

(property-list-p 1) => NIL
(property-list-p '(1 2 3)) => NIL
(property-list-p '(foo)) => NIL
(property-list-p nil) => T
(property-list-p '(foo 1)) => T
(property-list-p '(:a 1 :b 2)) => T

tuple

Function: (tuple &rest args)

Exactly same as LIST.

tuplep

Function: (tuplep object)

Returns true if object is a tuple, meaning a proper list.

Examples:

(tuplep 1) => NIL
(tuplep '(1 . 2)) => NIL
(tuplep nil) => T
(tuplep '(1 2 3)) => T

type-expand

Function: (type-expand type-specifier &optional env)

Expand type-specifier in the lexical environment env.

type-specifier-p

Function: (type-specifier-p type-specifier)

Returns true if type-specifier is a valid type specfiier.

TRIVIAL-PACKAGE-LOCAL-NICKNAMES

Version: 0.2
Licence: Public Domain
Repository: phoe/trivial-package-local-nicknames

A portability layer for package local nicknames.

add-package-local-nickname

Function: (add-package-local-nickname local-nickname actual-package &optional
           (package-designator (sane-package)))

Adds local-nickname for actual-package in the designated package, defaulting to current package. local-nickname must be a string designator, and actual-package must be a package designator.

Returns the designated package.

Signals a continuable error if local-nickname is already a package local nickname for a different package, or if local-nickname is one of "CL", "COMMON-LISP", or, "KEYWORD", or if local-nickname is a global name or nickname for the package to which the nickname would be added.

When in the designated package, calls to FIND-PACKAGE with the local-nickname will return the package the designated actual-package instead. This also affects all implied calls to FIND-PACKAGE, including those performed by the reader.

When printing a package prefix for a symbol with a package local nickname, local nickname is used instead of the real name in order to preserve print-read consistency.

See also: package-local-nicknames, package-locally-nicknamed-by-list, remove-package-local-nickname, and the DEFPACKAGE option :LOCAL-NICKNAMES.

Experimental: interface subject to change.

package-local-nicknames

Function: (package-local-nicknames package-designator)

Returns an alist of (local-nickname . actual-package) describing the nicknames local to the designated package.

When in the designated package, calls to FIND-PACKAGE with the any of the local-nicknames will return the corresponding actual-package instead. This also affects all implied calls to FIND-PACKAGE, including those performed by the reader.

When printing a package prefix for a symbol with a package local nickname, the local nickname is used instead of the real name in order to preserve print-read consistency.

See also: add-package-local-nickname, package-locally-nicknamed-by-list, remove-package-local-nickname, and the DEFPACKAGE option :LOCAL-NICKNAMES.

Experimental: interface subject to change.

package-locally-nicknamed-by-list

Function: (package-locally-nicknamed-by-list package-designator)

Returns a list of packages which have a local nickname for the designated package.

See also: add-package-local-nickname, package-local-nicknames, remove-package-local-nickname, and the DEFPACKAGE option :LOCAL-NICKNAMES.

Experimental: interface subject to change.

remove-package-local-nickname

Function: (remove-package-local-nickname old-nickname &optional
           (package-designator (sane-package)))

If the designated package had old-nickname as a local nickname for another package, it is removed. Returns true if the nickname existed and was removed, and NIL otherwise.

See also: add-package-local-nickname, package-local-nicknames, package-locally-nicknamed-by-list, and the DEFPACKAGE option :LOCAL-NICKNAMES.

Experimental: interface subject to change.