Dr who
Dr who

Reputation: 7

What is happening inside the scope of frozenset(...)? [Python3, Deterministic Finite Automata]

I'm currently analyzing some automata code that's written in Python 3. Unfortunately, I don't know enough about Python 3, as I thought I did. Here's some background: I'm currently analyzing a piece of code for the closure property ("concatenation") for a Deterministic Finite Automaton. We can assume that M = (Q, Sigma, Delta, q, F) be a DFA. Inside the concatenation closure property, is a piece of code written below. Can someone describe to me what is happening inside the scope of frozenset(...)?

delta = dict()
        for q in QA:
            for a in SigmaA:
                delta[((1,q),a)] = frozenset({ (1,r) for r in deltaA[(q,a)] })

Upvotes: 0

Views: 63

Answers (1)

Dr who
Dr who

Reputation: 7

After hours of research, and friends who helped. I got the answer to this problem of mine. Apparently, inside the scope, is something called "set comprehension" for python sets. Here's a link: Python Set Comprehension.

In laden terms (or for the lazy): The value found by the tuple key is something like a list or dict, which is being used for the dict comprehension.

Upvotes: 1

Related Questions