diff options
author | Vincent Ambo <mail@tazj.in> | 2021-12-15T20·10+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2021-12-15T21·02+0000 |
commit | 28ac55e94a4c71c1594d7ec51846315aed03e815 (patch) | |
tree | 3cedf2ff4a608605163b848c727690a39821ee10 /third_party/lisp/alexandria/binding.lisp | |
parent | 50b43cfb66a46fb5579e71d0e55174bb77fa2858 (diff) |
chore(3p/lisp): Unvendor alexandria and use nixpkgs sources r/3254
Change-Id: Idee3cb18ac42bd820d87aac0c68206436c1f4691 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4338 Autosubmit: tazjin <mail@tazj.in> Tested-by: BuildkiteCI Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'third_party/lisp/alexandria/binding.lisp')
-rw-r--r-- | third_party/lisp/alexandria/binding.lisp | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/third_party/lisp/alexandria/binding.lisp b/third_party/lisp/alexandria/binding.lisp deleted file mode 100644 index 37a3d52fb9f0..000000000000 --- a/third_party/lisp/alexandria/binding.lisp +++ /dev/null @@ -1,90 +0,0 @@ -(in-package :alexandria) - -(defmacro if-let (bindings &body (then-form &optional else-form)) - "Creates new variable bindings, and conditionally executes either -THEN-FORM or ELSE-FORM. ELSE-FORM defaults to NIL. - -BINDINGS must be either single binding of the form: - - (variable initial-form) - -or a list of bindings of the form: - - ((variable-1 initial-form-1) - (variable-2 initial-form-2) - ... - (variable-n initial-form-n)) - -All initial-forms are executed sequentially in the specified order. Then all -the variables are bound to the corresponding values. - -If all variables were bound to true values, the THEN-FORM is executed with the -bindings in effect, otherwise the ELSE-FORM is executed with the bindings in -effect." - (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings))) - (list bindings) - bindings)) - (variables (mapcar #'car binding-list))) - `(let ,binding-list - (if (and ,@variables) - ,then-form - ,else-form)))) - -(defmacro when-let (bindings &body forms) - "Creates new variable bindings, and conditionally executes FORMS. - -BINDINGS must be either single binding of the form: - - (variable initial-form) - -or a list of bindings of the form: - - ((variable-1 initial-form-1) - (variable-2 initial-form-2) - ... - (variable-n initial-form-n)) - -All initial-forms are executed sequentially in the specified order. Then all -the variables are bound to the corresponding values. - -If all variables were bound to true values, then FORMS are executed as an -implicit PROGN." - (let* ((binding-list (if (and (consp bindings) (symbolp (car bindings))) - (list bindings) - bindings)) - (variables (mapcar #'car binding-list))) - `(let ,binding-list - (when (and ,@variables) - ,@forms)))) - -(defmacro when-let* (bindings &body body) - "Creates new variable bindings, and conditionally executes BODY. - -BINDINGS must be either single binding of the form: - - (variable initial-form) - -or a list of bindings of the form: - - ((variable-1 initial-form-1) - (variable-2 initial-form-2) - ... - (variable-n initial-form-n)) - -Each INITIAL-FORM is executed in turn, and the variable bound to the -corresponding value. INITIAL-FORM expressions can refer to variables -previously bound by the WHEN-LET*. - -Execution of WHEN-LET* stops immediately if any INITIAL-FORM evaluates to NIL. -If all INITIAL-FORMs evaluate to true, then BODY is executed as an implicit -PROGN." - (let ((binding-list (if (and (consp bindings) (symbolp (car bindings))) - (list bindings) - bindings))) - (labels ((bind (bindings body) - (if bindings - `(let (,(car bindings)) - (when ,(caar bindings) - ,(bind (cdr bindings) body))) - `(progn ,@body)))) - (bind binding-list body)))) |