Containers.md
In this passage I’ll show the notes of Containers in CS_61A.
Box-and-Pointer Notation
This is just an easy diagrams to show lists in Environment Diagrams like this
Processing Container Values
Several built-in functions take iterable arguments and aggregate them into a value.
sum
- sum(iterable) -> value
- sum(iterable, start) -> value
This expression return the sum of an iterable of numbers (Not strings) plus the value of parameter ‘start’ (which defaults to 0). When the iterable is empty, return start.
examples:
1 | sum([2,3,4]) |
Max
- max(iterable) -> value
- max(iterable, key=func) -> value
- max(a, b, c, …) -> value
- max(a, b, c,…, key=func) -> value
With a single iterable argument , return its largest item.
with two or more arguments, return the largest argument.
example:
1 | max(1, 2, 3, 4) |
All
- all(iterable) -> bool
Return True if bool(x) is True for all values x in the iterable.
If the iterable is empty, return True.
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来源 HaoIne!