Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
假设我们定义了一棵整数树:
type inttree = Int of int | Node of inttree * inttree ;;
有没有办法找到那棵树的元素之和?
尝试一个简单的递归函数(进行深度优先遍历),例如
let rec mysum t = match t with Int x -> x | Node (l,r) -> mysum l + mysum r ;;
第一行可能是let rec mysum = function(这是风格问题)。
let rec mysum = function