Tips and Traps¶
list
is essentially a resizable array of objects in Python.Almosts all methods of list are in-place.
list.pop
is inplace and returns the removed element.To get unique elements in a list, you can first coerce the list to a set and then convert the set back to a list.
unique_list = list(set(alist))
Collections and Iterators in C++
Collections
-
Prefer
std::deque
tostd::vector
when the size of the collection is unknow. -
Suppose set
A
andB
are two set with the same type and setC
is another set with the same value type but a different comparison function, then it is still valid to insert …
Unpacking Assignment in Python
The unpacking assignment assigns elements of a tuple/list to variables at once.
List Running Jupyter Notebook Servers
You can list running Jupyter Notebook servers using the following command.
jupyter notebook list
It works well most of the time. However, if the servers are launched using the root account (e.g., in a Docker container), you might encounter issues. In this case, a better alternative is to list …
Useful Packages and Commands for LaTex
Math Packages
- \usepackage{amssymb}
- popular math fonts
- \usepackage{dsfont}
\mathds
font
- \usepackage{bm} % bold math symbols
- bold math symbols
- \usepackage{amsmath}
- math formulas.
- \usepackage{amsthm}
- theorem environments
- proof enviroment
List Packages
- \usepackage{enumerate}
- universal list
Graphics Packages
- \usepackage{ifpdf}
- allow including figures without extensions and select the right type of …