小编Kaf*_*Law的帖子

编写一个计算玫瑰树中元素数量的函数

编写一个计算玫瑰树中元素数量的函数。

我试过计算一​​棵玫瑰树中元素的数量。

data RoseTree a = RoseNode a [RoseTree a]
    deriving Show
things :: RoseTree String
things = 
    RoseNode "thing" [
        RoseNode "animal" [
            RoseNode "cat" [], RoseNode "dog" []
        ],

        RoseNode "metal" [
            RoseNode "alloy" [
                RoseNode "steel" [], RoseNode "bronze" []
            ],
            RoseNode "element" [
                RoseNode "gold" [], RoseNode "tin" [], RoseNode "iron" []
            ]
        ],

        RoseNode "fruit" [
            RoseNode "apple" [
                RoseNode "Granny Smith" [], RoseNode "Pink Lady" []
            ],
            RoseNode "banana" [],
            RoseNode "orange" []
        ], …
Run Code Online (Sandbox Code Playgroud)

haskell

-1
推荐指数
1
解决办法
146
查看次数

标签 统计

haskell ×1