I want to define a function that takes in a vector and outputs a vector $f(x,y) = (x+1,y-1)$ with the intention of computing composition $f^n(x,y)$.

I tried


None of these works when I do


Can anyone please help?

  • 5
    $\begingroup$ f[{x_, y_}] = {x+1, y-1}; $\endgroup$
    – march
    Mar 6, 2020 at 17:07
  • $\begingroup$ Or f = X \[Function] {Indexed[X, 1] + 1, Indexed[X, 2] - 1}. $\endgroup$ Mar 6, 2020 at 17:21
  • 3
    $\begingroup$ Experimenting with syntax can be a good way to try to get to a solution, but in the end you have it keep in mind that you are just guessing, and guesses will inevitably be incorrect sometimes (most of the time). If the guess didn't work, it's time to read the docs, and to go through a beginner's tutorial which explains that lists are enclosed in {, } (not in ( ) or [ ]). $\endgroup$
    – Szabolcs
    Mar 6, 2020 at 17:56

1 Answer 1


The problem originates from that you define the behavior of f as a function taking two variables and outputting one List, so when you feed the output of your inner f to the outer one, you are essentially feeding only one variable. Try the answers in the comments.


Not the answer you're looking for? Browse other questions tagged or ask your own question.