[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

*From*: Stephan Merz <stephan.merz@xxxxxxxxx>*Date*: Wed, 21 Oct 2020 17:33:46 +0200*References*: <777d286f-858b-42c2-ac89-1d2eac77f01en@googlegroups.com> <B6601963-34E5-412A-BAB2-3CBEEEC0B736@gmail.com> <8e33ff4b-097b-43a8-b58a-e35010782ae2n@googlegroups.com> <D6B92ECC-5325-4ADA-99BA-59CC601B9260@gmail.com> <3d3b91e7-4ad0-4bd3-93b2-20e9f800a6e4n@googlegroups.com> <75847d4b-4d20-4b19-86ca-f7653292137cn@googlegroups.com>

Hi José, in that case I'd suggest using a recursive definition such as the one below. In my original answer to Mariusz I tried to avoid using recursion, but this requires bounding the base set of sequences, which makes TLC balk when the sets are heterogeneous. I haven't tried writing a Java override of the operator definition. Regards, Stephan (***************************************************************************) (* Given a sequence s = <<S1, ..., Sn>> of sets, Cartesian(s) computes the *) (* n-ary Cartesian product of these sets, i.e. the set of all sequences *) (* whose i-th element belongs to the set Si. For example, *) (* Cartesian(<<{1,2}, {"a", "b"}, {{}}>>) = *) (* {<<1, "a", {}>>, <<1, "b", {}>>, <<2, "a", {}>>, <<2, "b", {}>>} *) (***************************************************************************) RECURSIVE Cartesian(_) Cartesian(s) == IF s = << >> THEN { << >> } ELSE LET C == Cartesian(Tail(s)) AllCons(seq) == { <<x>> \o seq : x \in Head(s) } IN UNION { AllCons(seq) : seq \in C }
You received this message because you are subscribed to the Google Groups "tlaplus" group. To unsubscribe from this group and stop receiving emails from it, send an email to tlaplus+unsubscribe@xxxxxxxxxxxxxxxx. To view this discussion on the web visit https://groups.google.com/d/msgid/tlaplus/C19D59F6-A17E-4DF9-AFC6-146D390148FD%40gmail.com. |

**Follow-Ups**:**Re: [tlaplus] n-ary Cartesian product***From:*JosEdu Solsona

**References**:**[tlaplus] n-ary Cartesian product***From:*Mariusz Ryndzionek

**Re: [tlaplus] n-ary Cartesian product***From:*Stephan Merz

**Re: [tlaplus] n-ary Cartesian product***From:*Mariusz Ryndzionek

**Re: [tlaplus] n-ary Cartesian product***From:*Stephan Merz

**Re: [tlaplus] n-ary Cartesian product***From:*Mariusz Ryndzionek

**Re: [tlaplus] n-ary Cartesian product***From:*JosEdu Solsona

- Prev by Date:
**[tlaplus] Integers Standard Module Location** - Next by Date:
**Re: [tlaplus] Integers Standard Module Location** - Previous by thread:
**Re: [tlaplus] n-ary Cartesian product** - Next by thread:
**Re: [tlaplus] n-ary Cartesian product** - Index(es):