Generate a DAG from a poset using stricly functional programming
问题 Here is my problem: I have a sequence S of (nonempty but possibly not distinct) sets s_i, and for each s_i need to know how many sets s_j in S (i ≠ j) are subsets of s_i. I also need incremental performance: once I have all my counts, I may replace one set s_i by some subset of s_i and update the counts incrementally. Performing all this using purely functional code would be a huge plus (I code in Scala). As set inclusion is a partial ordering, I thought the best way to solve my problem would