TomasVercetti Я бы и сам хотел, чтобы нашёлся человек, способный разъяснить некоторые вещи. Например:
In[1]:= Table[{y*x, y = x^2}, {x, 1, 10}]
Out[1]= {{100, 1}, {2, 4}, {12, 9}, {36, 16}, {80, 25}, {150,
36}, {252, 49}, {392, 64}, {576, 81}, {810, 100}}
Каким образом первое значение оказалось 100???
Добавлено: Хотя при более вдумчивом анализе всё становится понятно (используем
[no]On[][/no]):
[more=Результат при включённом On][no]In[1]:= On[];
Table[{y*x, y = x^2}, {x, 1, 10}]
During evaluation of In[1]:= On::trace: On[] --> Null. >>
During evaluation of In[1]:= CompoundExpression::trace: On[]; --> Null. >>
During evaluation of In[1]:= x::trace: x --> 1. >>
During evaluation of In[1]:= Times::trace: y x --> y 1. >>
During evaluation of In[1]:= Times::trace: y 1 --> y. >>
During evaluation of In[1]:= x::trace: x --> 1. >>
During evaluation of In[1]:= Power::trace: x^2 --> 1^2. >>
During evaluation of In[1]:= Power::trace: 1^2 --> 1. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=1. >>
During evaluation of In[1]:= Set::trace: y=1 --> 1. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {y,1}. >>
During evaluation of In[1]:= y::trace: y --> 1. >>
During evaluation of In[1]:= x::trace: x --> 2. >>
During evaluation of In[1]:= Times::trace: y x --> 1 2. >>
During evaluation of In[1]:= Times::trace: 1 2 --> 2. >>
During evaluation of In[1]:= x::trace: x --> 2. >>
During evaluation of In[1]:= Power::trace: x^2 --> 2^2. >>
During evaluation of In[1]:= Power::trace: 2^2 --> 4. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=4. >>
During evaluation of In[1]:= Set::trace: y=4 --> 4. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {2,4}. >>
During evaluation of In[1]:= y::trace: y --> 4. >>
During evaluation of In[1]:= x::trace: x --> 3. >>
During evaluation of In[1]:= Times::trace: y x --> 4 3. >>
During evaluation of In[1]:= Times::trace: 4 3 --> 12. >>
During evaluation of In[1]:= x::trace: x --> 3. >>
During evaluation of In[1]:= Power::trace: x^2 --> 3^2. >>
During evaluation of In[1]:= Power::trace: 3^2 --> 9. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=9. >>
During evaluation of In[1]:= Set::trace: y=9 --> 9. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {12,9}. >>
During evaluation of In[1]:= y::trace: y --> 9. >>
During evaluation of In[1]:= x::trace: x --> 4. >>
During evaluation of In[1]:= Times::trace: y x --> 9 4. >>
During evaluation of In[1]:= Times::trace: 9 4 --> 36. >>
During evaluation of In[1]:= x::trace: x --> 4. >>
During evaluation of In[1]:= Power::trace: x^2 --> 4^2. >>
During evaluation of In[1]:= Power::trace: 4^2 --> 16. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=16. >>
During evaluation of In[1]:= Set::trace: y=16 --> 16. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {36,16}. >>
During evaluation of In[1]:= y::trace: y --> 16. >>
During evaluation of In[1]:= x::trace: x --> 5. >>
During evaluation of In[1]:= Times::trace: y x --> 16 5. >>
During evaluation of In[1]:= Times::trace: 16 5 --> 80. >>
During evaluation of In[1]:= x::trace: x --> 5. >>
During evaluation of In[1]:= Power::trace: x^2 --> 5^2. >>
During evaluation of In[1]:= Power::trace: 5^2 --> 25. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=25. >>
During evaluation of In[1]:= Set::trace: y=25 --> 25. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {80,25}. >>
During evaluation of In[1]:= y::trace: y --> 25. >>
During evaluation of In[1]:= x::trace: x --> 6. >>
During evaluation of In[1]:= Times::trace: y x --> 25 6. >>
During evaluation of In[1]:= Times::trace: 25 6 --> 150. >>
During evaluation of In[1]:= x::trace: x --> 6. >>
During evaluation of In[1]:= Power::trace: x^2 --> 6^2. >>
During evaluation of In[1]:= Power::trace: 6^2 --> 36. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=36. >>
During evaluation of In[1]:= Set::trace: y=36 --> 36. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {150,36}. >>
During evaluation of In[1]:= y::trace: y --> 36. >>
During evaluation of In[1]:= x::trace: x --> 7. >>
During evaluation of In[1]:= Times::trace: y x --> 36 7. >>
During evaluation of In[1]:= Times::trace: 36 7 --> 252. >>
During evaluation of In[1]:= x::trace: x --> 7. >>
During evaluation of In[1]:= Power::trace: x^2 --> 7^2. >>
During evaluation of In[1]:= Power::trace: 7^2 --> 49. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=49. >>
During evaluation of In[1]:= Set::trace: y=49 --> 49. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {252,49}. >>
During evaluation of In[1]:= y::trace: y --> 49. >>
During evaluation of In[1]:= x::trace: x --> 8. >>
During evaluation of In[1]:= Times::trace: y x --> 49 8. >>
During evaluation of In[1]:= Times::trace: 49 8 --> 392. >>
During evaluation of In[1]:= x::trace: x --> 8. >>
During evaluation of In[1]:= Power::trace: x^2 --> 8^2. >>
During evaluation of In[1]:= Power::trace: 8^2 --> 64. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=64. >>
During evaluation of In[1]:= Set::trace: y=64 --> 64. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {392,64}. >>
During evaluation of In[1]:= y::trace: y --> 64. >>
During evaluation of In[1]:= x::trace: x --> 9. >>
During evaluation of In[1]:= Times::trace: y x --> 64 9. >>
During evaluation of In[1]:= Times::trace: 64 9 --> 576. >>
During evaluation of In[1]:= x::trace: x --> 9. >>
During evaluation of In[1]:= Power::trace: x^2 --> 9^2. >>
During evaluation of In[1]:= Power::trace: 9^2 --> 81. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=81. >>
During evaluation of In[1]:= Set::trace: y=81 --> 81. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {576,81}. >>
During evaluation of In[1]:= y::trace: y --> 81. >>
During evaluation of In[1]:= x::trace: x --> 10. >>
During evaluation of In[1]:= Times::trace: y x --> 81 10. >>
During evaluation of In[1]:= Times::trace: 81 10 --> 810. >>
During evaluation of In[1]:= x::trace: x --> 10. >>
During evaluation of In[1]:= Power::trace: x^2 --> 10^2. >>
During evaluation of In[1]:= Power::trace: 10^2 --> 100. >>
During evaluation of In[1]:= Set::trace: y=x^2 --> y=100. >>
During evaluation of In[1]:= Set::trace: y=100 --> 100. >>
During evaluation of In[1]:= List::trace: {y x,y=x^2} --> {810,100}. >>
During evaluation of In[1]:= Table::trace: Table[{y x,y=x^2},{x,1,10}] --> {{y,1},{2,4},{12,9},{36,16},{80,25},{150,36},{252,49},{392,64},{576,81},{810,100}}. >>
During evaluation of In[1]:= y::trace: y --> 100. >>
During evaluation of In[1]:= List::trace: {y,1} --> {100,1}. >>
During evaluation of In[1]:= List::trace: {{y,1},{2,4},{12,9},{36,16},{80,25},{150,36},{252,49},{392,64},{576,81},{810,100}} --> {{100,1},{2,4},{12,9},{36,16},{80,25},{150,36},{252,49},{392,64},{576,81},{810,100}}. >>
Out[2]= {{100, 1}, {2, 4}, {12, 9}, {36, 16}, {80, 25}, {150,
36}, {252, 49}, {392, 64}, {576, 81}, {810, 100}}[/no][/more]
Добавлено: Цитата: Глядя на функциональный язык математики, интересно, можно ли в итерации изнутри списка сослаться на текущее (Evaluated) значение другого элемента этого же списка?
Можно, если этот элемент выполняется раньше - думаю, после моих примеров это должно быть очевидно.