The mutility Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The mutility Reference Manual

This is the mutility Reference Manual, version 0.5, generated automatically by Declt version 3.0 "Montgomery Scott" on Mon Apr 19 17:09:47 2021 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

#+TITLE: mutility

modula's many-multi mega-miscellaneous meta-modulated macro-mutated utilities

A collection of various utility functions and macros I use in my libraries.

This is mostly for deduplication of code so I don't have to keep several copies of these functions across different projects. I don't really recommend depending on this library in your code since I may rename, rearrange, or remove things without warning. That being said, if you have any issues or need help with the library, please don't hesitate to let me know.

All exported symbols are documented via their docstrings, which are of course accessible via Lisp's standard ~documentation~ and ~describe~ functions.

* Noteworthy features

** Sugar

*** ~a~ macro

Quickly generate lists containing repeated items or numeric series.

#+BEGIN_SRC lisp
;; four 4s:
(a 1 4!4 2) ;=> (1 4 4 4 4 2)

;; 10 random numbers:
(a 'hello (random 10)!10 'goodbye) ;=> (HELLO 2 5 3 9 5 0 9 1 9 6 GOODBYE)

;; series from -2 to 2:
(a 'foo -2..2 'bar) ;=> (FOO -2 -1 0 1 2 BAR)
#+END_SRC

*** ~fn~ macro

A sweeter way to write ~lambda~. Underscore (~_~) is treated as the argument of the lambda.

#+BEGIN_SRC lisp
(fn (random 10))
;; is the same as
(lambda () (random 10))

;; and
(fn (+ 2 _))
;; is the same as
(lambda (_) (+ 2 _))
#+END_SRC

*** ~keys~ generic

Get a list of the keys of hash tables, plists, and anything else that defines a method for it. For example, [[https://github.com/defaultxr/cl-patterns][cl-patterns]] defines a method for its ~event~ class.

#+BEGIN_SRC lisp
(keys '(:foo 1 :bar 2)) ;=> (:FOO :BAR)

(keys (alexandria:plist-hash-table (list :this 1337 :that 69))) ;=> (:THIS :THAT)
#+END_SRC

** Strings

*** ~concat~

Concatenate its non-nil inputs together into a string, similar to the elisp function of the same name.

#+BEGIN_SRC lisp
(defun say-hello (name &optional ask)
  (concat "Hello, " name "!" (when ask " How are you doing today?")))

(say-hello "Allison" t) ;=> "Hello, Allison! How are you doing today?"
(say-hello "Gordon" nil) ;=> "Hello, Gordon!"
#+END_SRC

*** ~parse-boolean~

Parse a string as a boolean by looking for common true/false inputs like y/n, 1/0, on/off, true/false, enable/disable, etc. If the input is not a known boolean-like string, defaults to the specified default value

#+BEGIN_SRC lisp
(parse-boolean "1") ;=> t
(parse-boolean "0") ;=> nil
(parse-boolean "y") ;=> t
(parse-boolean "N") ;=> nil
(parse-boolean "blah" t) ;=> t ;; "blah" can't be interpreted as a boolean, so it defaults to the provided value of t.
#+END_SRC

*** "friendly string" functions

A few functions to generate more human-readable strings from numeric values.

#+BEGIN_SRC lisp
;; turn improper fractions into proper ones:
(friendly-ratio-string 13/4) ;=> "3 1/4"
(friendly-ratio-string 99/13) ;=> "7 8/13"

;; turn a number of seconds into the typical time notation:
(friendly-duration-string 67) ;=> "1:07"
;; 3600 seconds is one hour:
(friendly-duration-string 3600) ;=> "1:00:00"
#+END_SRC

** Math

*** ~wrap~

Wrap a number within a range like ~cl:mod~ but taking into account a lower bound as well.

*** rounding functions
Round, floor, or ceiling to the nearest multiple of a given number with ~round-by~, ~floor-by~, and ~ceiling-by~.

#+BEGIN_SRC lisp
(round-by 0.39 0.2) ;=> 0.4
(round-by 97 25) ;=> 100

(floor-by 0.39 0.2) ;=> 0.2
(floor-by 97 25) ;=> 75

(ceiling-by 0.22 0.2) ;=> 0.4
(ceiling-by 27 25) ;=> 50
#+END_SRC

** Sequences

*** ~length-upto~

Count the number of items in a list, not counting beyond a specified number.

#+BEGIN_SRC lisp
(length-upto (make-list 2000) 20) ;=> 20
#+END_SRC

*** ~most~

Get the most X item in a list, where X can be any comparison function. Similar to the standard ~reduce~ function, except that the ~key~ argument is only used for comparison, and the actual item from the list is still returned.

#+BEGIN_SRC lisp
;; get the item with the smallest car:
(most '< '((2 :bar) (3 :baz) (1 :foo)) :key 'car) ;=> (1 :FOO)

;; compare this to `reduce', which returns the result of calling KEY on the item, instead of returning the item itself:
(reduce 'min '((2 :bar) (3 :baz) (1 :foo)) :key 'car) ;=> 1
#+END_SRC

*** ~flatten-1~

Like ~alexandria:flatten~ but only flattens one layer.

*** ~subseq*~

Like the standard ~subseq~, but the START and END parameters can be negative to represent indexing from the end of the list.

#+BEGIN_SRC lisp
(subseq* (list 0 1 2 3 4 5) -3) ;=> (3 4 5)
(subseq* (list 0 1 2 3 4 5) -3 -1) ;=> (3 4)
#+END_SRC

*** ~left-trim~

Like ~string-left-trim~ but for lists instead of strings.

# FIX: describe +.x when it's fully implemented
# *** ~+.x~

** Randomness

*** ~random-coin~

*** ~random-range~

*** ~exponential-random-range~

*** ~random-gauss~

** Hash Tables

*** save and restore

** Miscellaneous

*** ~open-url~

*** ~generate-temporary-file-name~

** Swank Extensions

** Ranges

Functionality for mapping numbers from one range to another.

** ~defgeneric*~

** ~defclass*~

** Looping

Looping functionality is in the "loopy" subsystem; run ~(ql:quickload :mutility/loopy)~ to load it.

*** ~mapcar*~ and ~dolist*~

Like the standard ~mapcar~ and ~dolist~, but includes the current index into the list.

*** ~while~ macro

Your standard "while" loop that repeats its body as long as its test condition is true. Additionally, it will return the last non-nil value it processed in the body or the test.

*** ~do-while~ macro

Like ~while~, but the body is run before the test condition is checked; i.e. the body is always run at least once.

*** ~until~ macro

The opposite of ~while~; runs its body as long as its test condition is false.

*** ~accumulating~ macro

Efficiently append to a list, which is then returned.

#+BEGIN_SRC lisp
(accumulating (dotimes (n 5) (accumulate (random 10)))) ;=> (0 2 3 4 1)
#+END_SRC

* Sub-systems

- ~mutility/loopy~ is a small collection of various looping constructs like ~dolist*~, ~while~, ~do-while~, etc.
- ~mutility/generic-cl~ defines a few extensions to the [[https://github.com/alex-gutev/generic-cl][generic-cl]] library.
- ~mutility/test-helpers~ includes a few functions that are mostly useful for test suites.
- ~mutility/tests~ is the FiveAM-based test suite for the library.

* Tour

All source files are in the ~src/~ directory.

- [[file:src/package.lisp][package.lisp]] - the package definition file.
- [[file:src/mutility.lisp][mutility.lisp]] - mutility's "standard" functionality.
- [[file:src/sugar.lisp][sugar.lisp]] - syntax shorteners and sweeteners.
- [[file:src/ranges.lisp][ranges.lisp]] - define and translate between different types of ranges.
- [[file:src/test-helpers.lisp][test-helpers.lisp]] - a few introspection functions to make testing easier.
- [[file:src/loopy.lisp][loopy.lisp]] - various looping primitives.
- [[file:src/scrapyard.lisp][scrapyard.lisp]] - failed experiments, old versions, and other code refuse.

Mutility also includes a few extensions for other systems in ~src/extensions/~:

- [[file:src/extensions/generic-cl-extensions.lisp][generic-cl-extensions.lisp]] - extensions to the generic-cl library. FIX
- [[file:src/extensions/cl-org-mode-extensions.lisp][cl-org-mode-extensions.lisp]] - extensions to the cl-org-mode library. FIX
- [[file:src/extensions/swank-extensions.lisp][swank-extensions.lisp]] - extensions to swank. FIX

The test suite is located in ~t/~. To run the tests:

#+BEGIN_SRC lisp
(asdf:test-system :mutility)
#+END_SRC

* Future
Ideas, and things that need to be done.

- Come up with a better name for the ~a~ macro.
- Remove/rename ~accumulate~ to prevent clashes with generic-cl's ~accumulate~ function.
- Write functions to parse docstrings (i.e. to extract example code from them so they can be treated as tests).
- Write more tests for everything.
- Test docstring examples with the docstring-parsing function once it's written.
- Write a test to check for symbol clashes against various other libraries: ~alexandria~, ~serapeum~, ~cl-patterns~, ~thundersnow~, etc.
- Maybe split out stuff into subsystems? i.e. ~sugar~, ~files~, etc.
- Allow ~fn~ to accept more than one argument.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 mutility

Author

modula t.

Contact

defaultxr at gmail dot com

Home Page

https://github.com/defaultxr/mutility

Source Control

(:git "git@github.com:defaultxr/mutility.git")

Bug Tracker

https://github.com/defaultxr/mutility/issues

License

MIT

Description

modula’s utilities

Version

0.5

Dependencies
Source

mutility.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 mutility.asd

Location

/home/quickref/quicklisp/dists/quicklisp/software/mutility-20210411-git/mutility.asd

Systems

mutility (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 mutility/package.lisp

Parent

mutility (system)

Location

package.lisp

Packages

mutility


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 mutility/mutility.lisp

Dependency

package.lisp (file)

Parent

mutility (system)

Location

mutility.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Previous: , Up: Packages   [Contents][Index]

4.1 mutility

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: a &rest ARGS

Quickly and conveniently generate lists. Use ! to denote repetition of the previous element, or .. to denote a range.

Inspired by similar functionality in SuperCollider.

Examples:

;; (a 3!3)
;; => (3 3 3)
;;
;; (a -5 (random 3)!5 9 10)
;; => (-5 0 2 2 1 2 9 10)
;;
;; (a 2..9)
;; => (2 3 4 5 6 7 8 9)

See also: ‘repeat-by-!’, ‘expand-ranges’

Package

mutility

Source

mutility.lisp (file)

Macro: affixnew PLACE THING

Affix THING to the end of PLACE if it’s not already a member.

See also: ‘alexandria:appendf’, ‘cl:pushnew’.

Package

mutility

Source

mutility.lisp (file)

Macro: define-obsolete-function-alias OLD-FUNCTION-NAME NEW-FUNCTION-NAME

Define an alias for an obsolete function. The alias will warn about the obsolete function when it is used.

Package

mutility

Source

mutility.lisp (file)

Macro: dprint &rest ARGS

Easy macro to get debug output for a list of variables, ARGS. For each argument in ARGS, print the argument itself, then print what it evaluates to. Returns the last value.

Example:

;; (dprint (random 10) (+ 2 2))

...prints something like the following:
(RANDOM 10): 6; (+ 2 2): 4;
...and returns the value 4.

Package

mutility

Source

mutility.lisp (file)

Macro: fn &body BODY

Syntax sugar for making ‘lambda’s. BODY is the function body. Underscores in the body can be used to represent the argument to the function.

Package

mutility

Source

mutility.lisp (file)

Macro: with-access SLOTS INSTANCE &body BODY

Like ‘with-accessors’ and ‘with-slots’ combined; any slots provided as symbols are assumed to refer to both the variable name and the accessor. If no such accessor exists, just grab the slot as per ‘with-slots’.

Example:

If FOO is a function and BAR is not:

;; (with-access (foo bar) blah
;; (format t "~s ~s~%" foo bar))

...is the same as:

;; (with-accessors ((foo foo)) blah
;; (with-slots (bar) blah
;; (format t "~s ~s~%" foo bar)))

See also: ‘cl:with-accessors’, ‘cl:with-slots’

Package

mutility

Source

mutility.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Compiler macros

Compiler Macro: round-by-direction &rest ARGS
Package

mutility

Source

mutility.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Functions

Function: ceiling-by NUMBER &optional BY

Round NUMBER up to the next multiple of BY.

See also: ‘cl:ceiling’, ‘floor-by’, ‘round-by’

Package

mutility

Source

mutility.lisp (file)

Function: concat &rest OBJECTS

Concatenates all OBJECTS together into a string (other than nils, which are skipped).

See also: ‘cl:concatenate’, ‘uiop:strcat’

Package

mutility

Source

mutility.lisp (file)

Function: current-seconds ()

Get the number of seconds that Lisp has been running for.

Package

mutility

Source

mutility.lisp (file)

Function: elt-wrap SEQUENCE N

Get the Nth item in SEQUENCE, wrapping the index if necessary.

Much like ‘elt’, this function can be used on any sequence. However, because this function calls ‘length’ to determine the wrapped index, it may be slow when used on large lists. Consider using ‘nth-wrap’ in those cases instead.

See also: ‘nth-wrap’

Package

mutility

Source

mutility.lisp (file)

Function: exponential-random-range LOW HIGH

Generate a random number between LOW and HIGH, with exponential distribution.

See also: ‘random-range’, ‘random-gauss’

Package

mutility

Source

mutility.lisp (file)

Function: find-any ITEMS LIST &key TEST

Returns the first item from ITEMS that is found in LIST, or nil if none.

Package

mutility

Source

mutility.lisp (file)

Function: flatten-1 LIST

Like ‘alexandria:flatten’, but only flattens one layer.

Example:

;; (flatten-1 ’(1 (2 (3 4) 5) 6))
;; ;=> (1 2 (3 4) 5 6)

See also: ‘alexandria:flatten’

Package

mutility

Source

mutility.lisp (file)

Function: floor-by NUMBER &optional BY

Round NUMBER down to the previous multiple of BY.

See also: ‘cl:floor’, ‘ceiling-by’, ‘round-by’

Package

mutility

Source

mutility.lisp (file)

Function: fold NUMBER &optional BOTTOM TOP

Fold numbers outside BOTTOM and TOP back into the range.

Examples:

;; (fold -1 0 1) ;=> 1
;; (fold 5 0 10) ;=> 5
;; (fold 8 0 7) ;=> 6

See also: ‘wrap’, ‘cl:mod’, ‘alexandria:clamp’

Package

mutility

Source

mutility.lisp (file)

Function: friendly-duration-string SECONDS

Format a number of seconds as a more human-readable string. For now, hours are the biggest unit considered.

Example:

;; (friendly-duration-string 300) ;=> "5:00"
;; (friendly-duration-string 3600) ;=> "1:00:00"

See also: ‘friendly-ratio-string’

Package

mutility

Source

mutility.lisp (file)

Function: friendly-ratio-string RATIO &optional SEPARATOR

Format a ratio as a more human-readable string.

Example:

;; (friendly-ratio-string 5/4) ;=> "1 1/4" ;; (friendly-ratio-string 9/7) ;=> "1 2/7"

See also: ‘friendly-duration-string’

Package

mutility

Source

mutility.lisp (file)

Function: friendly-symbol INPUT &optional PACKAGE

Return INPUT as a symbol, with all non-letter, non-number, and non-hyphen characters removed.

Example:

;; (friendly-symbol "foo’s bar, baz, and qux") ;=> :FOOS-BAR-BAZ-AND-QUX

See also: ‘parse-boolean’, ‘friendly-ratio-string’, ‘friendly-duration-string’

Package

mutility

Source

mutility.lisp (file)

Function: function-arglist FUNCTION

Get the signature of FUNCTION.

Package

mutility

Source

mutility.lisp (file)

Function: generate-temporary-file-name &key NAME DIRECTORY EXTENSION

Generate a string representing a full path to a new temporary file. The file name defaults to a timestamp. Will automatically create DIRECTORY if it doesn’t exist. Will also attempt to generate a new name if a file with that name already exists.

Example:

;; (generate-temporary-file-name :name "foo" :directory "/tmp/lisp/" :extension "wav")
;; => "/tmp/lisp/foo.wav"

;; (generate-temporary-file-name :directory "/tmp/lisp/" :extension :flac)
;; => "/tmp/lisp/2020-04-20-06-09-00.flac"

Package

mutility

Source

mutility.lisp (file)

Function: insert-if FUNCTION LIST ITEM

Destructively insert ITEM into LIST at the position where FUNCTION is true. If the function doesn’t return true, the item is inserted at the end of the list. Similar to ‘nreverse’, the result is returned ;; FIX

Example:

;; (insert-if #’plusp (list -2 -1 1 2) 0)
;; ;; => (-2 -1 0 1 2)

See also: ‘insert-sorted’

Package

mutility

Source

mutility.lisp (file)

Function: insert-sorted LIST NUMBER

Destructively insert NUMBER into LIST in order.

Example:

;; (insert-sorted (list 1 2 3 4) 2.5)
;; ;; => (1 2 2.5 3 4)

See also: ‘insert-if’

Package

mutility

Source

mutility.lisp (file)

Function: left-trim BAG LIST &key TEST

Trim anything from BAG from the start of LIST.

See also: ‘cl:string-left-trim’

Package

mutility

Source

mutility.lisp (file)

Function: length-upto LIST &optional MAX

Get the length of LIST, not counting above MAX.

Example:

;; (length-upto (make-list 200) 20) ;=> 20

See also: ‘alexandria:length=’

Package

mutility

Source

mutility.lisp (file)

Function: lisp-connections ()

Get a list of the current connections to this Lisp image.

Package

mutility

Source

mutility.lisp (file)

Function: locate-dominating-file DIRECTORY NAME

Starting at DIRECTORY, look for a file named NAME in the current directory and successive parents, returning the first one found or nil if none.

Similar to the Emacs function "locate-dominating-file".

Package

mutility

Source

mutility.lisp (file)

Function: most FUNCTION LIST &key KEY

Get the most FUNCTION item in LIST by comparing the KEY of each item with FUNCTION. Unlike ‘reduce’, this function returns the whole item from LIST, even when KEY is provided.

Example:

;; get the item in the list with the smallest car:
;; (most ’< ’((2 :bar) (3 :baz) (1 :foo)) :key ’car) ;=> (1 :FOO)

See also: ‘cl:reduce’, ‘cl:find-if’

Package

mutility

Source

mutility.lisp (file)

Function: my-intern STRING &optional PACKAGE

Converts STRING into a symbol, uppercasing it in the process.

See also: ‘reintern’, ‘un-intern’

Package

mutility

Source

mutility.lisp (file)

Function: nth-wrap N LIST

Get the Nth item in LIST, wrapping the index if necessary.

Much like ‘nth’, this function can only be used on lists. Use ‘elt-wrap’ to index into any kind of sequence. However, keep in mind that ‘elt-wrap’ may be slower when used on large lists.

See also: ‘elt-wrap’

Package

mutility

Source

mutility.lisp (file)

Function: open-url URL

Open a URL via the OS’s default application.

Package

mutility

Source

mutility.lisp (file)

Function: output &rest ITEMS

Concatenates and prints ITEMS, returning the last one.

See also: ‘concat’

Package

mutility

Source

mutility.lisp (file)

Function: parse-boolean STRING &optional DEFAULT

Parse STRING as a boolean, returning either t or nil, or DEFAULT if it is not a known boolean string.

Package

mutility

Source

mutility.lisp (file)

Function: pretty-print-tree TREE &optional INDENT

Pretty print TREE, indenting the elements of each sublist.

Package

mutility

Source

mutility.lisp (file)

Function: random-coin &optional PROBABILITY

Randomly return true with a probability of PROBABILITY/1.

Package

mutility

Source

mutility.lisp (file)

Function: random-gauss MEAN STANDARD-DEVIATION

Generate a random number from a normal (Gaussian) distribution.

See also: ‘random-range’, ‘exponential-random-range’

Package

mutility

Source

mutility.lisp (file)

Function: random-range LOW &optional HIGH

Return a random number between LOW and HIGH, inclusive. If HIGH is not provided, act the same as (random LOW).

See also: ‘exponential-random-range’, ‘random-gauss’

Package

mutility

Source

mutility.lisp (file)

Function: reintern SYMBOL &optional PACKAGE

Reintern a symbol, changing its package to PACKAGE.

See also: ‘my-intern’, ‘un-intern’

Package

mutility

Source

mutility.lisp (file)

Function: replace-all STRING PART REPLACEMENT &key TEST

Get a new string in which all the occurences of the part is replaced with replacement.

See also: ‘cl-ppcre:regex-replace-all’

Package

mutility

Source

mutility.lisp (file)

Function: restore-hash-table FILENAME &rest MAKE-HASH-TABLE-ARGS

Restore a hash table from a file saved with the ‘save-hash-table’ function.

Example:

;; (restore-hash-table "/home/user/blah.hash")
;; ;=> #<HASH-TABLE ...>

See also: ‘save-hash-table’

Package

mutility

Source

mutility.lisp (file)

Function: round-by NUMBER &optional BY

Round NUMBER to the nearest multiple of BY.

Examples:

;; (round-by 1 2) ;; => 0
;; (round-by 1.1 0.5) ;; => 1.0
;; (round-by 6 10) ;; => 10

See also: ‘cl:round’, ‘floor-by’, ‘ceiling-by’

Package

mutility

Source

mutility.lisp (file)

Function: round-by-direction NUMBER &optional BY

Deprecated; use either ‘floor-by’, ‘ceiling-by’, or ‘round-by’ instead.

Package

mutility

Source

mutility.lisp (file)

Function: save-hash-table HASH FILENAME &key IF-EXISTS

Save a hash table to a file. See ‘restore-hash-table’ to load the saved table.

Example:

;; (save-hash-table *my-hash* "/home/user/blah.hash" :if-exists :rename)

See also: ‘restore-hash-table’

Package

mutility

Source

mutility.lisp (file)

Function: split-sequence SEQUENCE DELIMITER

Split SEQUENCE by DELIMITER.

Package

mutility

Source

mutility.lisp (file)

Function: split-string STRING &key MAX-NUM CHAR-BAG INCLUDE-EMPTY

Split STRING into a list of substrings by partitioning by the characters in CHAR-BAG, optionally to a list of maximum size MAX-NUM. If INCLUDE-EMPTY is true, include empty strings in the resulting list (and length count); otherwise exclude them.

Example:

;; (split-string "this that the other thing")
;; ;=> ("this" "that" "the" "other" "thing")

;; (split-string " foo bar baz qux " :max-num 2)
;; ;=> ("foo" "bar baz qux ")

See also: ‘split-sequence’, ‘str:split’, ‘split-sequence:split-sequence’

Package

mutility

Source

mutility.lisp (file)

Function: subseq* SEQUENCE START &optional END

Like subseq, but allows start and end to be negative.

Package

mutility

Source

mutility.lisp (file)

Function: un-intern SYMBOL

Converts a symbol into a string.

See also: ‘reintern’, ‘my-intern’

Package

mutility

Source

mutility.lisp (file)

Function: wrap NUMBER &optional BOTTOM TOP

Wraps a number between BOTTOM and TOP, similar to ‘cl:mod’.

Examples:

;; (wrap 2 0 1) ;; => 0
;; (wrap 5 0 10) ;; => 5
;; (wrap 15 0 10) ;; => 4

See also: ‘fold’, ‘cl:mod’, ‘alexandria:clamp’

Package

mutility

Source

mutility.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Generic functions

Generic Function: keys OBJECT

Get the keys of OBJECT, whether it be a plist, event, etc.

Package

mutility

Source

mutility.lisp (file)

Methods
Method: keys (OBJECT hash-table)
Method: keys (OBJECT cons)
Method: keys (OBJECT null)

Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Special variables

Special Variable: *deprecated-function-warning-round-by-direction-notified-p*
Package

mutility

Source

mutility.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Functions

Function: expand-ranges LIST

Expand ranges denoted by a..b in list.

Example:

;; (expand-ranges ’(0..5 -2..2)) ;; => (0 1 2 3 4 5 -2 -1 0 1 2)

Package

mutility

Source

mutility.lisp (file)

Function: prepend-list-to-sublists LIST

Prepend the symbol ’list to LIST and all of its sublists.

Package

mutility

Source

mutility.lisp (file)

Function: random-range.new LOW &optional HIGH

Return a random number between LOW and HIGH, inclusive. If HIGH is not provided, act the same as (random LOW).

Package

mutility

Source

mutility.lisp (file)

Function: repeat ITEM NUM

Get a list containing NUM ITEMs. If ITEM is a function, return a list of NUM of the result of that function.

Package

mutility

Source

mutility.lisp (file)

Function: repeat-by OBJECT REPEATS &optional ADD-LIST

Returns a list of object repeated REPEATS times. If REPEATS is a list of multiple numbers, recursively repeat the generated lists.

When ADD-LIST is true, prepend ’list to each generated list.

Example:

;; (repeat-by 3 3)
;; => (3 3 3)
;;
;; (repeat-by 3 ’(3 2))
;; => ((3 3 3) (3 3 3))

See also: ‘repeat-by-!’, ‘a’

Package

mutility

Source

mutility.lisp (file)

Function: repeat-by-! LIST &optional ADD-LIST

Given LIST, repeat items marked with ! by the number after the !.

When ADD-LIST is true, prepend ’list to each generated list. This is useful if you’re using this function in a macro, such as the ‘a’ macro, which this function does all the heavy lifting for.

Examples:

;; (repeat-by-! ’(1!2))
;; => (1 1)
;;
;; (repeat-by-! ’(1!2!3))
;; => ((1 1) (1 1) (1 1))
;;
;; (repeat-by-! ’(1 (* 2 3)!2))
;; => (1 (* 2 3) (* 2 3))

See also: ‘repeat-by’, ‘a’

Package

mutility

Source

mutility.lisp (file)

Function: split-by-! STRING

Split STRING up by exclamation points.

Package

mutility

Source

mutility.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M  
Index Entry  Section

F
File, Lisp, mutility.asd: The mutility․asd file
File, Lisp, mutility/mutility.lisp: The mutility/mutility․lisp file
File, Lisp, mutility/package.lisp: The mutility/package․lisp file

L
Lisp File, mutility.asd: The mutility․asd file
Lisp File, mutility/mutility.lisp: The mutility/mutility․lisp file
Lisp File, mutility/package.lisp: The mutility/package․lisp file

M
mutility.asd: The mutility․asd file
mutility/mutility.lisp: The mutility/mutility․lisp file
mutility/package.lisp: The mutility/package․lisp file

Jump to:   F   L   M  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   C   D   E   F   G   I   K   L   M   N   O   P   R   S   U   W  
Index Entry  Section

A
a: Exported macros
affixnew: Exported macros

C
ceiling-by: Exported functions
Compiler Macro, round-by-direction: Exported compiler macros
concat: Exported functions
current-seconds: Exported functions

D
define-obsolete-function-alias: Exported macros
dprint: Exported macros

E
elt-wrap: Exported functions
expand-ranges: Internal functions
exponential-random-range: Exported functions

F
find-any: Exported functions
flatten-1: Exported functions
floor-by: Exported functions
fn: Exported macros
fold: Exported functions
friendly-duration-string: Exported functions
friendly-ratio-string: Exported functions
friendly-symbol: Exported functions
Function, ceiling-by: Exported functions
Function, concat: Exported functions
Function, current-seconds: Exported functions
Function, elt-wrap: Exported functions
Function, expand-ranges: Internal functions
Function, exponential-random-range: Exported functions
Function, find-any: Exported functions
Function, flatten-1: Exported functions
Function, floor-by: Exported functions
Function, fold: Exported functions
Function, friendly-duration-string: Exported functions
Function, friendly-ratio-string: Exported functions
Function, friendly-symbol: Exported functions
Function, function-arglist: Exported functions
Function, generate-temporary-file-name: Exported functions
Function, insert-if: Exported functions
Function, insert-sorted: Exported functions
Function, left-trim: Exported functions
Function, length-upto: Exported functions
Function, lisp-connections: Exported functions
Function, locate-dominating-file: Exported functions
Function, most: Exported functions
Function, my-intern: Exported functions
Function, nth-wrap: Exported functions
Function, open-url: Exported functions
Function, output: Exported functions
Function, parse-boolean: Exported functions
Function, prepend-list-to-sublists: Internal functions
Function, pretty-print-tree: Exported functions
Function, random-coin: Exported functions
Function, random-gauss: Exported functions
Function, random-range: Exported functions
Function, random-range.new: Internal functions
Function, reintern: Exported functions
Function, repeat: Internal functions
Function, repeat-by: Internal functions
Function, repeat-by-!: Internal functions
Function, replace-all: Exported functions
Function, restore-hash-table: Exported functions
Function, round-by: Exported functions
Function, round-by-direction: Exported functions
Function, save-hash-table: Exported functions
Function, split-by-!: Internal functions
Function, split-sequence: Exported functions
Function, split-string: Exported functions
Function, subseq*: Exported functions
Function, un-intern: Exported functions
Function, wrap: Exported functions
function-arglist: Exported functions

G
generate-temporary-file-name: Exported functions
Generic Function, keys: Exported generic functions

I
insert-if: Exported functions
insert-sorted: Exported functions

K
keys: Exported generic functions
keys: Exported generic functions
keys: Exported generic functions
keys: Exported generic functions

L
left-trim: Exported functions
length-upto: Exported functions
lisp-connections: Exported functions
locate-dominating-file: Exported functions

M
Macro, a: Exported macros
Macro, affixnew: Exported macros
Macro, define-obsolete-function-alias: Exported macros
Macro, dprint: Exported macros
Macro, fn: Exported macros
Macro, with-access: Exported macros
Method, keys: Exported generic functions
Method, keys: Exported generic functions
Method, keys: Exported generic functions
most: Exported functions
my-intern: Exported functions

N
nth-wrap: Exported functions

O
open-url: Exported functions
output: Exported functions

P
parse-boolean: Exported functions
prepend-list-to-sublists: Internal functions
pretty-print-tree: Exported functions

R
random-coin: Exported functions
random-gauss: Exported functions
random-range: Exported functions
random-range.new: Internal functions
reintern: Exported functions
repeat: Internal functions
repeat-by: Internal functions
repeat-by-!: Internal functions
replace-all: Exported functions
restore-hash-table: Exported functions
round-by: Exported functions
round-by-direction: Exported compiler macros
round-by-direction: Exported functions

S
save-hash-table: Exported functions
split-by-!: Internal functions
split-sequence: Exported functions
split-string: Exported functions
subseq*: Exported functions

U
un-intern: Exported functions

W
with-access: Exported macros
wrap: Exported functions

Jump to:   A   C   D   E   F   G   I   K   L   M   N   O   P   R   S   U   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
S  
Index Entry  Section

*
*deprecated-function-warning-round-by-direction-notified-p*: Internal special variables

S
Special Variable, *deprecated-function-warning-round-by-direction-notified-p*: Internal special variables

Jump to:   *  
S  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   M   P   S  
Index Entry  Section

M
mutility: The mutility system
mutility: The mutility package

P
Package, mutility: The mutility package

S
System, mutility: The mutility system

Jump to:   M   P   S