Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View YMD.lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
(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)))
View YMD.lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14
(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")))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.