How can I take a list and remove all empty elements...
{{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"nonempty element"}, {}, {}, {}, {}, {}}
Thanks Isaac, I'm really just starting out with Wolfram so I'm making basic errors. Problem solved!
The above code was Mma7. I tried the same in (the free) Wolfram|Alpha, and the (free) programming cloud which also returned,
Select[ {{}, {}, {2}, {}}, # != {}&] {2}
Would you try re-starting your kernel, clear memory with `Remove["Global'*"] (That is a "Global backtick Star" as the first line in your file) and then try again? I can't think of any other reasons why this would fail.
Thanks Isaac, but I can't seem to quite get this right...
In: sparse_list= {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {"nonempty element"}, {}}; Select[sparse_list, # != {} &]
Out: Pattern[]
Any thoughts?
This may be what you seek.
Select[list, # != {} &] (* Out:= {{"nonempty element"}} *)