Ben Chuanlong Du's Blog

And let it direct your passion with reason.

The list Collection in Python

Tips and Traps

  1. list is essentially a resizable array of objects in Python.

  2. Almosts all methods of list are in-place.

  3. list.pop is inplace and returns the removed element.

  4. 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

  1. Prefer std::deque to std::vector when the size of the collection is unknow.

  2. Suppose set A and B are two set with the same type and set C is another set with the same value type but a different comparison function, then it is still valid to insert …

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

  1. \usepackage{amssymb}
    • popular math fonts
  2. \usepackage{dsfont}
    • \mathds font
  3. \usepackage{bm} % bold math symbols
    • bold math symbols
  4. \usepackage{amsmath}
    • math formulas.
  5. \usepackage{amsthm}
    • theorem environments
    • proof enviroment

List Packages

  1. \usepackage{enumerate}
    • universal list

Graphics Packages

  1. \usepackage{ifpdf}
    • allow including figures without extensions and select the right type of …