mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-19 01:01:59 +03:00
196d08dd6d
* start implement drop spec * [RefC] remove vars after prim function call * [RefC] gc pointer processing changed * [RefC] fix memory leak in stringIteratorToString * [RefC] runtime.c refactoring * Implement basic reuse analisis * [RefC] do not delete reusable variables in value in let * [RefC] Use names instead tags in reuse map * [RefC] Don't set all fields to null in reuse constructor * Use record syntax in RefC * Add some utility functions to RefC * Sort output in garbageCollect refc test * Add memory leak test for RefC * [RefC] Remove variable only from body in let Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org> * [RefC] Remove borrowed set from env * [RefC] Use Ref variable for Enviroment instead of passing as an argument * [RefC] Use locally function as combinator * [RefC] removing unnecessary dup and remove during pattern matching * Update refcTests and refcMemoryLeakTests * Remove some test files * move CHANGELOG entry to CHANGELOG_NEXT * Move refc-memory tests * Change calling convention test * [RefC] [Test] Reuse test --------- Co-authored-by: G. Allais <guillaume.allais@ens-lyon.org> Co-authored-by: Mathew Polzin <matt.polzin@gmail.com>
24 lines
551 B
Idris
24 lines
551 B
Idris
module Main
|
|
|
|
data BTree a = Leaf
|
|
| Node (BTree a) a (BTree a)
|
|
|
|
insert : Ord a => a -> BTree a -> BTree a
|
|
insert x Leaf = Node Leaf x Leaf
|
|
insert x (Node l v r) = if (x < v) then (Node (insert x l) v r)
|
|
else (Node l v (insert x r))
|
|
|
|
treePrint : Show a => BTree a -> IO ()
|
|
treePrint (Node l v r) = do
|
|
treePrint l
|
|
printLn v
|
|
treePrint r
|
|
treePrint Leaf = pure ()
|
|
|
|
main : IO ()
|
|
main = do
|
|
let tree1 = insert 4 $ insert 2 Leaf
|
|
let tree2 = insert 5 $ insert 3 tree1
|
|
treePrint tree2
|
|
treePrint tree1
|