Skip to content

vedatechnologiesinc/marie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

464 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Marie

Overview

Marie is a tiny collection of Lisp utilities without external dependencies. LispWorks only.

Installation

Clone this repo to ~/common-lisp/, or any location that is visible to ASDF, like ~/.local/share/common-lisp/source/

mkdir -p ~/common-lisp
cd ~/common-lisp
git clone https://github.com/vedatechnologiesinc/marie

You can then load it with ASDF:LOAD-SYSTEM or QL:QUICKLOAD

CL-USER> (asdf:load-system :marie)
CL-USER> (ql:quickload :marie)

Components

Each section or component is designed to simplify and accelerate development that can be selectively used depending on the task at hand. You can explore all the functions listed in the table for more details.

Legend

LEGENDDESCRIPTION
mmacro
ffunction
vspecial variable (defvar)
pspecial variable (defparameter)
kconstant
ggeneric function
tmethod
cclass
ncondition
mmmodify macro
smsymbol macro
ytype
sstruct

Definitions

Exporting replacements for functions, macros, and other things. It has two variants: those with - are non-exporting, while those without are exporting.

Main symbols

EXPORTINGNON-EXPORTINGSTANDARD EQUIVALENT
DEFMDEFM-DEFMACRO
DEFDEF-DEFUN
DEF (SETF)DEF- (SETF)DEFUN (SETF)
DEFVDEFV-DEFVAR
DEFPDEFP-DEFPARAMETER
DEFKDEFK-DEFCONSTANT
DEFGDEFG-DEFGENERIC
DEFTDEFT-DEFMETHOD
DEFCDEFC-DEFCLASS
DEFNDEFN-DEFINE-CONDITION
DEFMMDEFMM-DEFINE-MODIFY-MACRO
DEFSMDEFSM-DEFINE-SYMBOL-MACRO
DEFYDEFY-DEFTYPE
DEFSDEFS-DEFSTRUCT
SETVSETV-SET-VARIABLE

Types

FUNCTIONARGSDESCRIPTION
SYMBOL-LISTN/AA list of symbols.
CHARACTER-LISTN/AA list of characters.
INTEGER-LISTN/AA list of integers.
STRING-LISTN/AA list of strings.

Additional symbols

FUNCTIONARGSDESCRIPTION
WITHARGS BODYBind ARGS and REST as either a single LET, named LET, DESTRUCTURING-BIND, MULTIPLE-VALUE-BIND, or normal LET.
λARGSBind ARGS for LAMBDA.
ARGSBind ARGS for PROGN.
PROGN!ARGSExecute BODY with speed optimizations.
PROGN@ARGSExecute BODY with safety optimizations.
CXRARGSAccess the element of TREE as denoted by the specifier X.

Reader

Minor tweaks with the Lisp reader’s behavior to add convenient syntactic shortcuts.

Shortcuts

FUNCTIONARGSDESCRIPTION
BRACE-READER (f)STREAM CHARUse {+ _ 1} as shorthand for #'(lambda (_) (+ _ 1)), reading from STREAM and ignoring CHAR.
BRACKET-READER (f)STREAM CHARUse [foo 5] as shorthand for (funcall foo 5), reading from stream and ignoring CHAR.
READ-FROM-STRING* (f)STRINGEvaluate STRING with preserved case.

Symbols

Utility functions for symbols and macro manipulation.

Show symbol functions

FUNCTIONARGSDESCRIPTION
SYMBOLS (f)PACKAGE TYPEReturns the symbols interned in PACKAGE by TYPE.
EXTERNAL-SYMBOLS (f)PACKAGEReturns the external symbols in PACKAGE.
PRESENT-SYMBOLS (f)PACKAGEReturns the present symbols in PACKAGE.
SYMBOLS*^SYMS (f)PACKAGE TYPEPrint the symbols in interned in PACKAGE by TYPE.
PRETTY-PRINT-SYMBOLS^PPS (f)PACKAGEDisplay the external symbols in PACKAGE in the order that they were declared as dependencies.

Macro utilities

FUNCTIONARGSDESCRIPTION
MACRO-EXPAND^MX (m)FORMPretty prints macro expansions of FORM.
WITH-GENSYMS (m)NAMES BODYEvaluate BODY where NAMES are unique symbols.
MACRO-APPLY^MAPPLY (m)MACRO ARGSInvoke the macro MACRO to each item in ARGS.
MBOUNDP (f)SYMBOLReturn true if SYMBOL is bound to a macro.
FLET* (m)BODYEvaluate BODY in LABELS.

Symbol manipulation macros

FUNCTIONARGSDESCRIPTION
FREE (m)ARG-1 ARG-2Unbind ARG-1 if ARG-2 is present, free ARG-2 in instance of ARG-1.
UNBIND (m)SYMBOLRemove the bindings of SYMBOL.
RENAME-MACRO (m)NAME-1 NAME-2Change the macro name from NAME-1 to NAME-2.
RENAME-SPECIAL-VARIABLE (m)NAME-1 NAME-2Update the special variable NAME-1 to NAME-2.
SWAP-SPECIAL-VARIABLES (m)NAME-1 NAME-2Swap the values of the special variables NAME-1 and NAME-2.
KEYWORD-USED-P^KUP (f)STRINGReturn true if keyword is already interned, accepting a STRING as the argument.

Conditionals

Utilities for handling conditional expressions and logical operations.

Mapping

FUNCTIONARGSDESCRIPTION
MAP-AND (m)FN ARGSReturn true if FN returns true for all items in ARGS.
MAP-OR (m)FN ARGSReturn true if FN returns true for at least one item in ARGS.
RMAP-AND (m)VALUE FNSReturn true if all functions in FNS return true for VALUE.
RMAP-OR (m)VALUE FNSReturn true if at least one function in FNS return true for VALUE.

Logical operator variants

FUNCTIONARGSDESCRIPTION
LOGICAL-AND^LAND^∧ (m)BODYReturn true if all forms in BODY evaluates to true.
LOGICAL-OR^LOR^∨ (m)BODYReturn true if at least one form in BODY evaluates to true.
NEGATION^NEG^¬ (m)ARGReturn the negation of ARG.
LOGICAL-AND-NOT^∧¬ (m)ARG1 ARG2Return true if ARG1 is true and ARG2 is not true.
LOGICAL-NOT-AND^¬∧ (m)ARG1 ARG2Return true if ARG1 is not true and ARG2 is true.
LOGICAL-OR-NOT^∨¬ (m)ARG1 ARG2Return true if ARG1 is true or ARG2 is not true.
LOGICAL-NOT-OR^¬∨ (m)ARG1 ARG2Return true if ARG1 is not true or ARG2 is true.
LOGICAL-NOT-NOT^¬¬ (m)ARG1 ARG2Return true if ARG1 is not true and ARG2 is not true.

When macro bindings

FUNCTIONARGSDESCRIPTION
WHEN-LET (m)BINDINGS FORMSUse BINDINGS like with LET, then evaluate FORMS if all BINDINGS evaluate to a true value.
WHEM-LET* (m)BINDINGS FORMSUse bindings like with LET*, then evaluate FORMS if all BINDINGS evaluate to a true value.

Boolean logic helpers

FUNCTIONARGSDESCRIPTION
TRUE-WHEN^ω (m)CONDITIONReturn true when CONDITION evaluates as true.
TRUE-FALSE-P (f)X YReturn true if X is true and Y is false.
FALSE-TRUE-P (f)X YReturn true if X is false and Y is true.
TRUE-TRUE-P (f)X YReturn true if X is true and Y is true.
AIF (m)TEST-FORM THEN-FORMAnaphora (α) IF, takes TEST-FORM, THEN-FORM and optionally else-form, binding the test result to it.
AWHEN (m)TEST-FORM THEN-FORMAnaphora (α) WHEN, takes TEST-FORM and a body THEN-FORM using aif to evaluate and bind it.
AAND (m)ARGSAnaphora (α) AND, takes multiple ARGS evaluating them with short-circuiting logic using AIF.
ACOND (m)CLAUSESAnaphora (α) COND, takes multiple CLAUSES evaluating them sequentially with an anaphoric binding.
NIF (m)TEST-FORM THEN-FORM ELSE-FORMNIF takes TEST-FORM THEN-FORM and optionally ELSE-FORM performing a negated if condition.

Sequences

Utilities for sequence manipulation.

List predicates

FUNCTIONARGSDESCRIPTION
LENGTH= (f)SEQ LENReturn true if the length of SEQ is equal to LEN.
LENGTH< (f)SEQ LENReturn true if the length of SEQ is less than to LEN.
LENGTH> (f)SEQ LENReturn true if the length of SEQ is greater than to LEN.
LENGTH<= (f)SEQ LENReturn true if the length of SEQ is less than or equal to LEN.
LENGTH>= (f)SEQ LENReturn true if the length of SEQ is greater than or equal to LEN.
SINGLEP (f)SEQReturn true if there is only one item in SEQ.
LONGERP (f)X YReturn true if X is longer than Y.

List transformation, manipulation and filtering

FUNCTIONARGSDESCRIPTION
FLATTEN-LIST (f)LISTMerge all symbols from LIST to one list.
APPEND* (f)LIST DATADestructively update LIST with DATA.
VECTOR-LIST (f)LISTReturn vector as LIST.
LIST-VECTOR (f)VECTORReturn list as VECTOR.
GROUP-ALIKE (f)LISTGroup similar elements together from GROUPS.
BUILD-LENGTH-INDEX (f)GROUPSReturn a hash table from a list of lists.
MAP-APPEND (f)FN SEQUENCE1 SEQUENCE2Apply APPEND to the result of applying FN to SEQUENCE1 and SEQUENCE2.
MAP-NCONC (f)FN SEQUENCE1 SEQUENCE2Apply NCONC to the result of applying FN to SEQUENCE1 and SEQUENCE2.
REDUCE-APPEND^*RED-APPEND (f)ARGSReduce ARGS with APPEND.
REDUCE-NCONC^RED-NCONC (f)ARGSReduce ARGS with NCONC.
REMOVE* (f)ELEMS VALUERemove all items in ELEMS in VALUE.
REMOVE-NIL (f)VALUERemove nil at any level of tree in VALUE.
BUTREST (f)LISTReturn everything from LIST except the rest.
INSERT-AFTER (f)LIST INDEX ITEMReturn a new list from LIST where ITEM is inserted after INDEX.
INSERT-BEFORE (f)LIST INDEX ITEMReturn a new list from LIST where ITEM is inserted after INDEX.
APPEND1 (f)LIST OBJApply APPEND to LIST and OBJ ensuring that OBJ is a list.
NCONC1 (f)LIST OBJApply NCONC to LIST and OBJ ensuring that OBJ is a list.
TRANSPOSE (f)LISTReturn a matrix transposition of LIST.
DELETE-FROM-PLISTF (f)KEYSModify macro for DELETE-FROM-PLIST in KEYS.
MAKE-EMPTY-LIST (f)OBJECTReturn an empty list from OBJECT.
GROUPS (f)LISTReturn decreasing order of groups from LIST.
PAIRS (f)LISTReturn pairs of lists from LIST.
ARRAY-TO-LIST (f)ARRAYReturn a list from ARRAY.
SHOW-LIST^LS (f)LIST FNDisplay the items in LIST according to FN, separated by newlines.
JOIN (f)LISTMerge items in LIST by the space character.
JOIN-STREAM (f)STREAM ENDRead lines from 1 to END from STREAM.
SEQUENCE-STRING (f)SEQReturn SEQ as a string.
ASSOC-KEY (f)KEY ITEMSReturn the key found in ITEMS if KEY is found.
ASSOC-VALUE (f)KEY ITEMSReturn the value found in ITEMS if KEY is found.
MASSOC (f)ATOM LISTReturn the first match on the LIST that takes ATOM as an input.
MEM (f)ELEM LISTReturn true if ELEM is a member of LIST using TEST as the equality FN.
MEM* (f)ELEMS LISTReturn true if all items ELEMS are members of LIST using test as the equality FN.
TAKE (f)SEQ COUNTReturn COUNT amount of items from SEQ.
DROP (f)SEQ COUNTReturn items from SEQ without the first COUNT items.
SINGLE (f)SEQReturn the only item in SEQ if SEQ has only one element.
END (f)SEQReturn the last element of SEQ.

List manipulation with ifs

FUNCTIONARGSDESCRIPTION
TAKE-IF (f)FN SEQ COUNTReturn COUNT amount of items from SEQ that satisfy FN.
DROP-IF (f)FN SEQ COUNTReturn items from SEQ without the first COUNT items that satisfy FN.
INCLUDE-IF (f)ARGSApply REMOVE-IF-NOT to ARGS.
FILTER-IF (f)FN LISTCollect the results of applying FN to LIST which returns true.
FILTER-IF-NOT (f)FN LISTCollect the results of applying FN to LIST which returns false.
PRUNE-IF (f)FN TREERemove all items from TREE to which FN returns true.
PRUNE-IF-NOT (f)FN TREERemove all items from TREE to which FN returns false.
LOCATE-IF (f)FN LISTmay ginagawa Find element in list satisfying FN. When found, return the car of LIST.
SPLIT-IF (f)FN LISTReturn two lists wherein the first LIST contains everything that satisfies FN.

Sequence predicates

FUNCTIONARGSDESCRIPTION
EVERY-LIST-P (f)OBJECTReturn true if OBJECT is a list and all members are lists.
BEFOREP (f)X Y LISTReturn true if X occurs before Y in LIST.
AFTERP (f)X Y LISTReturn true if X occurs after Y in LIST.
DUPLICATEP (f)X LISTReturn true if X has a duplicate in LIST.

Property list manipulation

FUNCTIONARGSDESCRIPTION
REMOVE-FROM-PLIST (f)PLIST KEYSReturns a property-list with same keys and values as PLIST, except that keys in the list designated by KEYS and values corresponding to them are removed.
REMOVE-FROM-PLISTF (mm)KEYSModify macro for REMOVE-FROM-PLIST which takes a multiple KEYS as an argument.
DELETE-FROM-PLIST (f)PLIST KEYSJust like REMOVE-FROM-PLIST with same KEYS, but this version may destructively modify the provided PLIST.

Miscellaneous sequence

FUNCTIONARGSDESCRIPTION
PARTITION (f)SOURCE NCreate partition of N from SOURCE.
PERMUTATIONS^PERMS (f)LISTReturn the permutations of LIST.
SCRAMBLE (t)SEQUENCE LISTReturn a randomized array or LIST from SEQUENCE.

Strings

Utilities for dealing with strings.

Formatting

FUNCTIONARGSDESCRIPTION
FMT (f)ARGSReturn a string with FORMAT in ARGS.
FMT* (f)ARGSPrint ARGS to stdout with FORMAT.
FMT-ERROR (f)STRINGOutput STRING to STANDARD-ERROR then return.

String transformation

FUNCTIONARGSDESCRIPTION
STRING* (f)OBJECTReturn OBJECT as a string.
LIST->STRING (f)LISTReturn the string version of LIST.
STRING->LIST (f)STRINGCreate a list from STRING.
STRING->INTEGER-LIST (f)STRINGParse integer and return N STRING into list.
CONCAT^CAT (f)ARGSConcatenate ARGS to a string.
REDUCE-CONCAT^RED-CAT (f)ARGSReduce ARGS with CONCAT.
INTERN-CONCAT^INT-CAT (f)PACKAGE ARGSConcatenate ARGS to a string then intern it to the current PACKAGE.
NORMALIZE-STRING (f)LIST CHARACTERReturn LIST of characters with equal length using CHARACTER as end padding.

Predicate FNS

FUNCTIONARGSDESCRIPTION
STRING-SUBSTRING-P (f)X YReturn true if X is part of Y, and that X is found from the start of Y.
EVERY-STRING-P (f)OBJECTReturn true if OBJECT is a list and all members are strings.
EMPTY-STRING-P (f)STRINGReturn true if STRING is of length zero.

Miscellaneous string

FUNCTIONARGSDESCRIPTION
GENSTRN/AReturn a random string.
EARMUFFARGSReturn a hyphenated symbol from ARGS with surrounding *s.
SEPARATORSSTRING FILTERReturn the separators used in STRING, applying FILTER to remove characters.
REMOVE-WHITESPACESTRINGReturn a new string from STRING without whitespace characters.
SEARCH-SUBSTRINGSTRING BAGReturn the index of STRING where the first appearance of items in BAG occurs.

Etc

Collection of miscellaneous utility functions.

Optimization

FUNCTIONARGSDESCRIPTION
DEBUG@ (m)N/AEnable compiler options for maximum debug options.
SAFETY@ (m)N/AEnable compiler options for maximum debug and safety options.
SPEED@ (m)N/AEnable compiler options for maximum speed options.

Debugging

FUNCTIONARGSDESCRIPTION
DBG (m)ARGSPrint information about ARGS, then return the result of evaluating ARGS.
DBG* (m)ARGS BODYPrint information about ARGS, evaluate BODY, then return the result of evaluating ARGS.
DBG1 (m)ARG BODYApply DBG to ARG, then evaluate BODY.
MUFFLE-DEBUGGER-HANDLER (f)CONDITION HOOKDefine a handler for muffling the debugger, ignoring hook and caught an error condition.
MUFFLE-DEBUGGER (f)N/AHide debugger message.
WITH-MUFFLED-DEBUGGER (m)BODYEvaluate BODY with the debugger warnings turned off.

Hyphen functions

FUNCTIONARGSDESCRIPTION
HYPHENATE-TO-STRING (f)NAMESReturn a new string from the hyphenated concatenation of NAMES.
HYPHENATE-TO-SYMBOL (f)NAMESApply HYPHENATE to NAMES then return it as a symbol.
HYPHENATE-TO-INTERNED-SYMBOL (f)PACKAGE NAMESApply HYPHENATE to NAMES then return an interned symbol in the current PACKAGE.

NULL

FUNCTIONARGSDESCRIPTION
EMPTY (m)OBJECTSet the value of OBJECT to null.
EMPTY* (m)OBJECTSSet the value of OBJECTS to null.
NULL* (f)VALUEReturn true if VALUE is null or every item is.

Miscellaneous etc

FUNCTIONARGSDESCRIPTION
WITH-TIME (m)BODYExecute BODY then return timing information.
TRUE (f)N/AReturn true for anything.
FALSE (f)N/AReturn false for anything.
GETUID (f)N/AReturn the real UID of the user.
EVAL-ALWAYS (m)BODYEvaluate the forms in BODY in all situations.
APPENDF (mm)LISTS APPENDSet the value of the first argument to the result of applying APPEND to LISTS.
MAXF (mm)NUMBERS MAXSet the value of the first argument to the result of applying MAX to NUMBERS.
MINF (mm)NUMBERS MINSet the value of the first argument to the result of applying MIN to NUMBERS.
DEFSELECTORS (m)PREFIX COUNTDefine list selectors prefixed with PREFIX that will act as sequence accessors.
FNS (m)FN ARGSReturn a function that applies FN and ARGS to OBJ that returns multiple values.
WITH-SUPPRESED-OUTPUT^MUTE (m)BODYEvaluate BODY but with output suppressed.
MULF (m)VAR NUMSet a new value for VAR by multiplying itself by a NUM.
PRN (f)OBJECTPrint OBJECT according to its type.
APROPOS* (f)ARGSDisplay sorted matching symbols from ARGS with CL:APROPOS.
COLLECT-CHARACTERS (f)START ENDCollect ASCII characters from START to END.
DOC (f)SYMBOLReturn the documentation strings of SYMBOL.

Hash tables

Utilities for working with hash tables.

Ordered hash table

FUNCTIONARGSDESCRIPTION
MAKE-ORDERED-HASH-TABLE (f)N/ACreate an ordered-hash-table with specified parameters.
PRINT-ORDERED-HASH-TABLE (f)HASH-TABLE STREAMPrints the ordered HASH-TABLE to the specified STREAM.
ORDERED-HASH-TABLE-COUNT (f)ORDERED-HASH-TABLE-COUNTReturns the number of key-value pairs in the ordered hash table.
GET-ORDERED-HASH (f)KEY HASH-TABLE DEFAULTFetches the value associated with KEY from the ordered HASH-TABLE.
REMOVE-ORDERED-HASH (f)KEY HASH-TABLERemoves the key-value pair associated with KEY from the ordered HASH-TABLE.
CLEAR-ORDERED-HASH (f)HASH-TABLEClears all key-value pairs from the ordered HASH-TABLE, resetting it to an empty state.
ORDERED-HASH-KEYS (f)HASH-TABLEReturns a list of keys in the ordered HASH-TABLE in reverse order.
SHOW-ORDERED-HASH-TABLE (f)HASH-TABLEPrints the contents of the ordered HASH-TABLE showing key-value pairs.
SHOW-ORDERED-HASH-TABLE* (f)HASH-TABLERecursively prints the contents of the ordered HASH-TABLE, formatting output with indentation for nested hash tables.
GET-ORDERED-HASH* (f)PATH HASH-TABLEFetches the value associated with the specified PATH (a list of keys) from the ordered HASH-TABLE. Allow nested lookups.

Miscellaneous hash table

FUNCTIONARGSDESCRIPTION
COPY-TABLE^COPYHASH (f)HASH-TABLEReturn a new copy of hashtable from HASH-TABLE.
HASH-TABLE-KEYS (f)HASH-TABLEReturn the keys of HASH-TABLE.
HASH-TABLE-VALUES (f)HASH-TABLEReturn the values of HASH-TABLE.
LIST-TABLE^LISTHASH (f)HASH-TABLE SORT KEYReturns an association list of key-value pairs from HASH-TABLE, optionally sorted by the provided SORT function using the KEY.
SHOW-TABLE (f)TABLEPrints the contents of the HASH-TABLE to standard output.
SHOW-TABLE* (f)TABLERecursively prints the contents of the HASH-TABLE with indentation for nested structures.
GETHASH* (f)PATH TABLEFetches a value from the HASH-TABLE by following the specified PATH (a list of keys).

Filesystem

Utilities for file operations and system management.

File directory related

FUNCTIONARGSDESCRIPTION
DIRECTORY-ENTRIES (f)DIRECTORYReturn top-level files and directories under DIRECTORY.
ENTRIES^FILES (f)LISTReturn all files for every directory found under LIST expansion.
READ-FILE-SEQUENCE (f)PATHRead entire file as byte sequence in PATH.
RESOLVE-SYSTEM-FILE (f)SYSTEMReturn the path of FILE relative to SYSTEM.
WITH-OUTPUT-FILE (m)VAR PATH BODYDefine a macro for thin wrapper over WITH-OPEN-FILE that takes an input of VAR, PATH, and BODY.
HOME^~ (f)PATHReturn a PATH relative to the home directory.
EXPAND-PATHNAME (f)PATHReturn a PATH while performing tilde expansion.
READ-INTEGER (f)STRINGReturn integer from STRING.
READ-INTEGER-LINE (f)FILEReturn integer from a line in FILE.
DISPLAY-FILE (f)FILEDisplay the contents of FILE.

System

FUNCTIONARGSDESCRIPTION
SYSTEM-OBJECT^SYS-OBJECT (f)SYSTEMReturn the system object for the current SYSTEM.
SYSTEM-PATH^SYS-PATH (f)SYSTEMReturn the ASDF file path for the current SYSTEM.
SYSTEM-VERSION^SYS-VERSION (f)SYSTEMReturn the version number extracted from the SYSTEM resources.

Project

Creates a project skeleton in Lisp.

Tree generation

FUNCTIONDESCRIPTION
MAKE-PROJECT (f)Make a complete project skeleton.
MAKE-SYSTEM (f)Make a basic project skeleton.

About

A tiny collection of Lisp utilities without external dependencies. LispWorks only.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors