I'm new in Mathematica and I am trying to write numbers from 1 to 10 in txt file. But "Null" is everything that is written in my file. The code is:
Export["C:\\Users\\Sealy\\Desktop\\list.txt",
For[k = 1, k <= 10, k++, Print[List[k]]]]
|
I'm new in Mathematica and I am trying to write numbers from 1 to 10 in txt file. But "Null" is everything that is written in my file. The code is:
|
|||||||||
|
|
Here are some variants to achieve what you want using various notations and avoiding the use of the dreaded Exporting as strings Standard notation:
Infix notation:
Exporting in Mathematica format Save as a list, so it can easily be read back into mathematica using
Read it back in using the short form of the function
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} Why you might not want a For loops aren't used very much in Mathematica as there are more efficient ways to approach the need to repeat computations. Lists are fundamental to what Mathematica does and in conjunction with other techniques such as Map The
Listability The ability of functions to apply themselves to a list,
Functions can Return Lists ( Here we use the short form of function invocation,
and
|
||||
|
|
|
Recommendation: Read up on
|
|||
|
|
|
Try this:
|
|||||||
|
|
Try
However the simplest Mathematica way to do it will be by calling
BR |
|||||||||||
|