茱莉亚·伊万斯

第31天:具有核心逻辑的二叉树!!

今天很有趣。

早上,我和威尔伯德关于某种逻辑编程。我们致力于实现核心逻辑在克洛杰里。我们找到了!我最喜欢的关于逻辑编程的事情就是所有的函数都以“o”结尾。

下面是我们的代码看起来像:

(ns核-逻辑-搜索-树.核心核心(:refer-clojure:..[=====..].(:refer-refer-clo-search-search-search-search-search-search-search-树.core-核心(ns核-逻辑-search-search-search-search-search-tree-search-tree-search-tree-search-tree.tree-search-tree-tree.search-tree.tree.core-search-run](:refer-refer-clo-clo-clojure-clojure-clojure-clojure-search-search-search-search-tree.tree.tree.tree.core(:refer-core-search-search-search-search-search-search-tree-search-tree-tree-tree-search-tree.core-tree(新鲜的[新鲜的](fd/in v(fd/.al 0 2000))(==tree[:value v:.l:right r])(conde[(fd/==v x)][(fd/>v x)(containso l x)][(fd/<v x)(containso r x)])

然后我们可以跑了

(运行1[q](containso my-tree 3))

也就是说,树包含3。没关系!但是真正有趣的部分是你可以运行它”向后“并要求

(运行10[q](containso q 3))

得到10棵包含3:

[:值3:左:左_0:左:右_0:右_1][:值4:左:左_0:左_0:右_1]:右_2][:值0:左_0:3:左_0:3:左_0:左_0:左_0:右_1][:值4:值4:左:左[:值4:左:3:3:左:左_0:左:右_1]:左_1]:左_1]:右_2][:值0:右_2][:值0:值0:0:0:左:0:左:左:左:左:左:左:左右_2][:value 7:.[:value 3:._0:right_1]:right_2][:value 8:.[:value 3:._0:right_1]:right_2][:value 2:._0:right[:value 3:._1:right_2][:value 9:.[:value 3:._0:right_1]:right_2])

如果你仔细检查,您将看到,这些都是二叉树,它们都包含3!=)

我也在和林赛一起做神奇的音乐魔术,但那得等到明天