Lab06 题解 (UCB CS61A@2021 Fall)


Write a function which takes in a list lst, an argument entry, and another argument elem. This function will check through each item in lst to see if it is equal to entry. Upon finding an item equal to entry, the function should modify the list by placing elem into lst right after the item. At the end of the function, the modified list should be returned.

Hw04 题解 (UCB CS61A@2021 Fall)


Implement the planet data abstraction by completing the planet constructor and the size selector so that a planet is represented using a two-element list where the first element is the string 'planet' and the second element is its size.

从问题的描述中我们可以知道什么是 planet. 就是一个长度为 2 的 list, 内容是 ['planet', size]. 可以参考 mobile 函数, 这两个函数的代码是很类似的

Lab05 题解 (UCB CS61A@2021 Fall)


Write factors_list, which takes a number n and returns a list of its factors in ascending order.

我们可以知道这么一个基本的数学事实: 一个数字的因子最大仅可能为它的一半(当这个数字是偶数的时候). 所以我们的 for 循环只要遍历到 n // 2 + 1 即可

How to Manage Windows Using Hammerspoon


虽然 macOS 自带窗口管理这个功能, 但是实际上是用下来发现还是很难受的. 功能不足以满足自己的需求. 所以我常常发现自己在用鼠标拖动窗口和重新调整窗口大小. 长此以往, 我觉得这样效率实在太低, 恰好前阵子在看 MIT-Missing-Semester 的课, 里面提到了 hammerspoon 这个工具. 我去稍微了解了一下发现这工具真的不错.