This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lvariations (list num) | |
(if (or (zerop num) (null list)) | |
(list nil) | |
(loop for elt in list | |
nconc (loop for subvariation in (lvariations (remove elt list) (1- num)) | |
collect (concatenate 'string elt subvariation))))) | |
(defun l-the-regexp-elements () | |
(nconc (delete-duplicates | |
(loop for i from 2 to 3 | |
nconc (loop for set in '(("YYYY" "MM" "DD") ("YY" "MM" "DD")) | |
nconc (lvariations set i))) | |
:test #'string=) | |
(list "YYYY" "YY" "MM" "DD"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun variations (list &optional (num (length list))) | |
(if (or (zerop num) (null list)) | |
(list nil) | |
(apply #'nconc | |
(mapcar #'(lambda (elt) | |
(mapcar | |
#'(lambda (subvariations) | |
(concatenate 'string elt subvariations)) | |
(variations (remove elt list) (1- num)))) | |
list)))) | |
(defun the-regexp-elements () | |
(delete-duplicates (nconc | |
(variations '("YYYY" "MM" "DD") 3) | |
(variations '("YYYY" "MM" "DD") 2) | |
(list "YYYY" "MM" "DD") | |
(variations '("YY" "MM" "DD") 3) | |
(variations '("YY" "MM" "DD") 2) | |
(list "YY")) | |
:test #'string=)) | |
(defun the-regexp () | |
(format nil "~{~A~^|~}" (the-regexp-elements))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment