Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'How can I eliminate Nulls from a list?' topicStudent Support Forum > General > "How can I eliminate Nulls from a list?"

Next Comment >Help | Reply To Topic
Author Comment/Response
Harry Pool
04/14/13 7:39pm

I'm building a list by appending consecutive approximations of the square root of 3 to the list. The resulting list has the expected approximations but each is followed with "Null".

Where are the "Null"s coming from? How can I stop them?

f[a_, x0_] :=
Module[{tries = {x0}, count = 0},
While[count < 7, (AppendTo[tries, (Last[tries]+a/Last[tries])/2.];
count++);]
tries]
f[3., 7.]

{7. Null, 3.714286 Null, 2.260989 Null, 1.793921 Null, 1.733118 Null, 1.732051 Null, 1.732051 Null, 1.732051 Null}

URL: ,

Subject (listing for 'How can I eliminate Nulls from a list?')
Author Date Posted
How can I eliminate Nulls from a list? Harry Pool 04/14/13 7:39pm
Re: How can I eliminate Nulls from a list? jf 04/14/13 8:11pm
Next Comment >Help | Reply To Topic