Is there a reason why sometimes, when using commands to open a notebook, instead of actually opening the notebook, it sometimes just returns "NotebookObject" followed by a number like 27 in a box?
A song I heard recently has somewhere a bit similar to mma's beep[]. But before I realized that, I was heavily looking for FrontEnd errors and checking messages settings :)
Is there a commonly known fastest way to remove an item from an unordered list? It appears that Complement[list, {val}] is a lot faster than DeleteCases[list, val], even though the former does an implicit sort.
Deleting a numeric element from a list doesn't require sorting. If the list is represented by a real C-Array, you need to copy the list into a new list which doesn't contain the element you want to delete.
The approach I would suggest is to just go through the list and insert each element that is not equal to the one you want to delete into a new dynamically growing list. I have a compiled version here that beats both, DeleteCases and Complement on large unordered real lists.
@C.E. I'm not sure. In highlevel Mathematica, a list is a list of expressions which internally are pointers. So I believe they need to take more cases under consideration. What I have for an unordered list of Reals is the following:
@halirutan Select[list, # != 0.01 &]; // AbsoluteTiming takes 4.91732 seconds for me, compared with 0.21 for your method. That's actually very surprising to me.
Pick[Unitize[list - 0.01], 1]; // AbsoluteTiming is faster though, taking only 0.17 seconds.
@J.M. Then I get 1.28873 seconds, so about the same.
@halirutan So to sum it up: deleteElement is the algorithmically best way to do it, but Pick[Unitize[list - val], 1] uses the hardware better? Could it be different with a better compiler?
Sow/Reap use bags internally, so Reap[Sow[#, # == 0.01] & /@ list, False]; // AbsoluteTiming should work similarly to deleteElement: Wrong. 10 seconds.