Personal utilities for Common Lisp.
Some functions are specific to SBCL.
This project is a kind of shelf providing many functions. With a few clearly indicated exceptions, these functions are self-supporting. They do not require any dependency, or to be built/integrated in any specific way. Because "the truly reusable code is the one that you can simply copy-paste".
When relevant, functions and macros are illustrated with SHOW-xxx.
The function (SHOW-all-cl-utils) defined in _show-all.lisp file executes most of the SHOW-xxx functions one after the other.
A test suite is proposed. In addition to traditional tests, when several implementations of the same function are proposed, tests files may (i) check that the various implementations yield the same results and (ii) compare speed (asd files specify (speed 3)).
File arrays-and-vectors
- general considerations
- functions
vec-view-all-contentandvec-preview - function
unliteral--fixnum-vector - in the tests: a benchmark showing that
svrefdoes not bring extra performance (at least with(speed 3)) - bit-vectors: see specific file below
File association-lists
- useful standard functions
File bit-vectors
- functions
fixnum->bit-vectorandbit-vector->fixnum - function
bit-vector-logcount - in the tests: a benchmark showing that, in order to reset a bit vector to zero, it is less costly to create a new one than to set each bit to zero individually.
File booleans
- macro
boolean-value
File compare-durations
- function
start-up-1 - macro
compare-durations
File dates-and-times
- function
universal-time-to-YYYYMMDD-HHMMSS - function
get-current-YYYYMMDD-HHMMSS - functions
convert-int-YYYYMMDD-and-HHMMSS-to-universal-timeandconvert-int-YYYYMMDD-to-universal-time - function
universal-time-to-YYYY-MM-DD - functions
pretty-print-universal-time-as-full-date-time,pretty-print-universal-time-as-long-dateandpretty-print-universal-time-as-short-date - function
pretty-print-time-difference
File debug
- SLDB commands: see Emacs related hydra
- function
debug-output
File equality
- considerations on equality predicates
File ffi-with-cffi
- function
SHOW-ffi-with-cffi
File ffi-with-sb-alien
- function
SHOW-ffi-with-sb-alien
File files
- function
random-file-name - function
reduce-for-each-line-of-file
File format
- illustrations of various
formatdirectives
File functions
- generalities on functions
- are arguments passed by reference of by value?
File hash-tables
- useful standard functions
File images
- function
draw-pic-from-rgb-arrays(uses zpng library) - function
draw-heatmap-from-values(uses zpng library)
File lists
- general considerations on lists
- function
delete-nthandreplace-nth - function
list-preview - functions
arg-minandarg-max - function
nb-of-occurrences-of-sublist-in-list - functions
make-circular-DO-NOT-PRINT--AND-NOT-LITERALandcircular-list-length - function
unliteral--fixnum-list
File macros
- macro
with-gensyms - macros
whileandwhile1 - macros
repeat-untilanddo-while - macros
aprognandablock - macros
setf-min,setf-max,setf-min--df,setf-max--df - macros
with-collectorandwith-collector--reversed-order - macro
let+
File mail-vis-gmail
- function
send-mail-via-gmail
File measure-duration
- function
SHOW-measure-duration - function
SHOW-benchmark-5-times-AandSHOW-benchmark-5-times-B - macro
with-timing
File numbers-doubles
- (void)
File numbers-integers
- function
reverse-number--fixnum
File numbers-integers-french
- function
en-toutes-lettres
File numbers-integers-primes
- function
largest-prime-factor - function
primep - function
next-prime - function
nth-prime
File numbers-rationals
- macro
convert-to-proper-fraction-m - function
length-of-recurring-cycle
File ollama
- function
call-ollama1(requires jonathan, dexador) - function
call-ollama2(requires jonathan, dexador, bordeaux-threads)
File optimization (how comply with 'speed 3' compilation notes?)
- general considerations and methods
- type
fixnum-range-double-float - macro
round-of-df - type
positive-fixnum-range-double-float - macro
floor-of-positive-df
+ a note about "doing float to pointer coercion (cost 13) to <return value>" compilation notes.
File parallelism
- multiple functions illustrating various methods
File property-lists
- useful standard functions
File strings
- useful standard functions
- function
string-split - function
substring-after-last - function
string-repeat-string - function
string-add-space-at-left - function
duplicate-strings-in-list - function
palindrome-string-p - function
unliteral--string
File symbols
- general considerations on symbols, including keywords, at the end of the file
- function
function-to-stringandfunction-to-string-no-package
File tco
- illustration that (speed 3) encourages tail-call optimization
File trampoline
- function
trampolineand example
File triangles
- function
triangle-to-2d-array
File types
- general considerations on types
File variables
- general considerations on variables
- explanations about bindings
- lexical vs dynamic scoping
File web
- function
web-redirect-p
Any comment? Open an issue, or start a discussion here or at profile level.
(end of README)