September 2017
Beginner to intermediate
396 pages
9h 46m
English
stack new binary-tree-functor simple
module Main where import Data.Functor
-- The tree can be empty (Leaf) or a node with a -- value, left and right trees. data Tree a = Leaf | Node (Tree a) a (Tree a) deriving (Show, Eq)
-- Create a tree given a value, left tree and a right tree node :: Tree a -> a -> Tree a -> Tree a node l x r = Node l x r
-- Induct a value into a new tree (node with empty left and right trees) singleton :: a ...
Read now
Unlock full access