I have a problem to nest a non pure function.The function f
has two arguments, i
and j
, it can come out four results {i + 2, j - 1}
, {i + 1, j}
, {i, j + 1}
, {i - 1, j + 2}
which I use If conditional to programme it. But now, what I want to do it's to nest this function, like I input i = 1
, j = 0
, then the four results will follow the F subsequently. it's like if I want nest it 3 times, then it should have 12 results. but the error show that "part specification [][]is longer than depth of the object".
Update
f = Function[{i, j},
If[(i > 0) && (j > 0),
{{i + 2, j - 1}, {i + 1, j}, {i, j + 1}, {i - 1, j + 2}},
If[j == 0,
{{i + 1, j}, {i, j + 1}, {i - 1, j + 2}},
{{i + 2, j - 1}, {i + 1, j}, {i, j + 1}}
]
]
];
This the function I use. I hope I can nest this function several times and get a long list results. The one step work for example put i = 1
, j = 1
, I get {{3, 0}, {2, 1}, {1, 2}, {0, 3}}
.
N
then there might be a problem. It's best not to use capitals as they conflict with built-in functions. $\endgroup$