相关疑难解决方法(0)

是否可以对使用结合策略构建的图形进行搜索?

结点策略可用于构建图形,例如,使用简单的双边图形作为示例:

data Node = Node Node Node

-- a - b
-- |   |
-- c - d
square = a where
    a = Node b c
    b = Node a d
    c = Node a d
    d = Node b c
Run Code Online (Sandbox Code Playgroud)

这个策略相当优雅,但是如果没有Int标签,我找不到实际使用它的方法.例如,我如何编写一个计算square值上节点数量的函数?

countNodes :: Node -> Int
countNodes = ... ??? ...

main = print $ countNodes square
-- output: 4
Run Code Online (Sandbox Code Playgroud)

haskell tying-the-knot

5
推荐指数
1
解决办法
178
查看次数

标签 统计

haskell ×1

tying-the-knot ×1