2019-03-11から1日間の記事一覧

3. 木構造の実装

問題 Given the root to a binary tree, implement serialize(root), which serializes the tree into a string, and deserialize(s), which deserializes the string back into the tree. 実装 再帰的に実装します。Noneでなければ展開するようにしています…

5. Pythonでcar,cdrの実装

内容 lispで使うcar, cdrをpythonで実装してみました。 def cons(a, b): def pair(f): return f(a, b) return pair def car(pair): def f(a, b): return a return pair(f) def cdr(pair): def f(a, b): return b return pair(f) if __name__ == "__main__": …