Last active
November 3, 2021 17:22
-
-
Save copecog/6bfb20e037075b0f1c207c8c192c18ab to your computer and use it in GitHub Desktop.
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
(deftype transit-char () `(or character (eql ε))) | |
(defun transit-char-closure (fa-states-prev fa-states-next Δ transit-char) | |
"Starting with and including FA-STATES-PREV, add all states reachable by TRANSIT-CHAR via map data structure Δ, to (=>) FA-STATES-NEXT." | |
(declare (type sets:set fa-states-prev fa-states-next) | |
(type maps:map Δ) | |
(type transit-char transit-char)) | |
(sets:set-do-elements (state-prev fa-states-prev fa-states-next); => fa-states-next | |
(unless (sets:set-get-element state-prev fa-states-next); If we haven't already looked at this state: | |
(sets:set-add-element state-prev fa-states-next); Add current state-prev state to fa-states-next. | |
(a:when-let ((state-prev->states (maps:map-get `(,state-prev ,transit-char) Δ))); If set of reachable states exists, | |
(transit-char-closure state-prev->states fa-states-next Δ transit-char))))); recurse to add them and what they can reach too. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment