Skip to main content
added 408 characters in body
Source Link
user21
  • 42.2k
  • 8
  • 116
  • 176
g[lists___List] := Module[{f}, f[___, x_, x_, ___] := Sequence[]; f[x___] := (f[x] = Sequence[]; {x}); Attributes[f] = {Orderless, Temporary}; Flatten[Outer[f, lists], Length[{lists}] - 1]] 

To address the comments let me put it another way: If you overwrite the attributes of course they are going to be 'lost'

Look at this:

g[lists___List] := Module[{f}, f[___, x_, x_, ___] := Sequence[]; f[x___] := (f[x] = Sequence[]; {x}); Print[Attributes[f]]; Attributes[f] = {Orderless}; Print[Attributes[f]]; Flatten[Outer[f, lists], Length[{lists}] - 1]] 
g[lists___List] := Module[{f}, f[___, x_, x_, ___] := Sequence[]; f[x___] := (f[x] = Sequence[]; {x}); Attributes[f] = {Orderless, Temporary}; Flatten[Outer[f, lists], Length[{lists}] - 1]] 
g[lists___List] := Module[{f}, f[___, x_, x_, ___] := Sequence[]; f[x___] := (f[x] = Sequence[]; {x}); Attributes[f] = {Orderless, Temporary}; Flatten[Outer[f, lists], Length[{lists}] - 1]] 

To address the comments let me put it another way: If you overwrite the attributes of course they are going to be 'lost'

Look at this:

g[lists___List] := Module[{f}, f[___, x_, x_, ___] := Sequence[]; f[x___] := (f[x] = Sequence[]; {x}); Print[Attributes[f]]; Attributes[f] = {Orderless}; Print[Attributes[f]]; Flatten[Outer[f, lists], Length[{lists}] - 1]] 
Source Link
user21
  • 42.2k
  • 8
  • 116
  • 176

g[lists___List] := Module[{f}, f[___, x_, x_, ___] := Sequence[]; f[x___] := (f[x] = Sequence[]; {x}); Attributes[f] = {Orderless, Temporary}; Flatten[Outer[f, lists], Length[{lists}] - 1]]