Haskell線段樹建樹

調了一晚上……

data Tree=Tree Int Int [Tree] [Tree]|Empty deriving (Show)

build :: (Int,Int)->Tree
build (x,y)=if x<y then Tree x y [build (x,(div (x+y) 2))] [build ((div (x+y) 2)+1,y)] else Tree x y [Empty] [Empty]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章