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

*From*: Stephan Merz <stephan.merz@xxxxxxxxx>*Date*: Wed, 6 Mar 2019 09:06:09 +0100*References*: <49fb73d6-681b-44b8-ab88-76d90400f7e1@googlegroups.com> <3cad7ec3-c02c-42f2-9938-da637704b9bb@googlegroups.com>

I believe that the post [1] on StackOverflow, with a link to a worked-out example on GitHub, should help you get started. If I understand correctly, the TLA+ specification of your operator would be Range(s) == { s[i] : i \in DOMAIN s } RECURSIVE PermSeqs(_,_) \* set of sequences of length k that are permutations of elements of sequence s
-- PermSeqs(s,k) == IF k=0 THEN { << >> } ELSE { t \in [1..k -> Range(s)] : \E i \in 1 .. Len(s) : /\ Head(t) = s[i] /\ Tail(t) \in PermSeqs(SubSeq(s,1,i-1) \o SubSeq(s,i+1,Len(s)), k-1) } For example, PermSeqs(<<1,2,2,3,4>>, 2) = { <<1, 2>>, <<1, 3>>, <<1, 4>>, <<2, 1>>, <<2, 2>>, <<2, 3>>, <<2, 4>>, <<3, 1>>, <<3, 2>>, <<3, 4>>, <<4, 1>>, <<4, 2>>, <<4, 3>> } PermSeqs(<<1,2>>, 3) = {} Stephan [1] https://stackoverflow.com/questions/53908653/use-module-overloading-to-implement-a-hash-function-in-tla
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 post to this group, send email to tlaplus@xxxxxxxxxxxxxxxx. Visit this group at https://groups.google.com/group/tlaplus. For more options, visit https://groups.google.com/d/optout. |

**Follow-Ups**:

**References**:

- Prev by Date:
**[tlaplus] Re: Write custom java code function plug-in for PLUSCAL/TLA to compute combinations on sequences w/ dups?** - Next by Date:
**Re: [tlaplus] Re: Write custom java code function plug-in for PLUSCAL/TLA to compute combinations on sequences w/ dups?** - Previous by thread:
**[tlaplus] Re: Write custom java code function plug-in for PLUSCAL/TLA to compute combinations on sequences w/ dups?** - Next by thread:
**Re: [tlaplus] Re: Write custom java code function plug-in for PLUSCAL/TLA to compute combinations on sequences w/ dups?** - Index(es):