0

I have two lists as follows:

{1,2,3} and {4,5,6}

And I have a function f

f[{1,2,3},{4,5,6}]:={{4,5,6},{1,2,3}};

I want

f[f[{1,2,3},{4,5,6}]]

But since the output of

f[{1,2,3},{4,5,6}]

has an extra parentheses, I cannot simply do it.

How to fix the problem so I can calculate

f[f[{1,2,3},{4,5,6}]]

and further

Nest[f,{{1,2,3},{4,5,6}},n]
ZHANG Juenjie
  • 1,121
  • 7
  • 13

1 Answers1

2

If I understand the question correctly, you could define f as

f[{l1_, l2_}] := {l2, l1}

Then,

f[{{1, 2, 3}, {4, 5, 6}}]
(* {{4, 5, 6}, {1, 2, 3}} *)

f[f[{{1, 2, 3}, {4, 5, 6}}]]
(* {{1, 2, 3}, {4, 5, 6}} *)
bbgodfrey
  • 61,439
  • 17
  • 89
  • 156