Smap
SmapIE
New program
Curry
Prolog
Haskell
Open program by ID
Browser
Dashboard
Programs on Smap
Most recent
Most favorited
Tags on Smap
All tags
Sign in
Help
Source code
Language:
Curry
-- This is a source code template for Curry programs. data Tree a = Empty | Node a (Tree a) (Tree a) deriving (Show) tree = Node 10 Empty Empty Insert :: (Ord a) => a -> Tree a -> Tree a Insert x Empty = Node x Empty Empty Insert x (Node y left right) | x == y = (Node y left right) | x < y = Node y (Insert x left) right | x > y = Node y left (Insert x right) Contains :: (Ord a) => a -> Tree a -> Bool Contains x Empty = False Contains x (Node y left right) | x == y = True | x < y = Contains x left | x > y = Contains x right tree2 = Insert 9 (Insert 12 (Insert 13 tree)) Remove2 x (Node x Empty Empty) = Empty Remove2 x (Node x left Empty) = left Remove2 x (Node x Empty right) = right --Remove :: (Ord a) => a -> Tree a -> Tree a Remove x Empty = Empty Remove x (Node y left right) | x == y = Remove2 x (Node y left right) | x < y = (Node y (Remove x left) right) | x > y = (Node y left (Remove x right)) main = Contains 13 tree2-- put here the main expression of your program
Execution result
No execution result yet.
PAKCS 3.7 /all-values
PAKCS 3.7 /one-value
KiCS2 3.1 /all-values
KiCS2 3.1 /one-value
Reset
Clear
Options
New Curry program
Reload program 77
View in Browser
Program ID:
77
Title:
Binary Tree
Language:
Curry
Author:
nikobro
Version:
3
Program information