Mercurial > hg > Members > toma > Jungle-haskell
annotate test/test.hs @ 10:29d0f605efa9
add updateRootNodeWith
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 21 Jan 2014 15:51:34 +0900 |
parents | 947c5cfa4149 |
children | 74a4c7cdc50b |
rev | line source |
---|---|
7 | 1 {-# LANGUAGE OverloadedStrings #-} |
2 | |
3 import Jungle | |
4 import Data.Maybe | |
5 import qualified Data.ByteString.Lazy.Char8 as B | |
6 | |
7 jungle = createJungle | |
8 | |
9 tree = do | |
10 a <- createTree jungle "test" | |
9
947c5cfa4149
Change function related to Tree, Tree is not visiable from outside.
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
8
diff
changeset
|
11 node <- getRootNode a "test" |
7 | 12 return (add node) |
13 | |
14 addc path pos node = addNewChildAt node path pos | |
15 | |
16 addchild = | |
17 (addc [3] 2) . (addc [] 3) . (addc [1,1] 2) . (addc [1,1] 1). (addc [2] 2) . (addc [1] 2) . | |
18 (addc [2] 1) . (addc [] 2). (addc [1] 1) . (addc [] 1) | |
19 | |
20 adda path key value node = putAttribute node path key value | |
21 | |
22 addattr = | |
23 (adda [1,1] "key" "value") . (adda [1,1] "test" "test2") . | |
24 (adda [] "root" "node") . (adda [1] "tes" "abc") . | |
25 (adda [3,2] "test" "3-2") . (adda [2,2] "test" "2-2") | |
26 | |
10
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
27 add :: Node -> Node |
7 | 28 add = addattr . addchild |
29 | |
10
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
30 putNode = putStrLn . drawNode |
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
31 putAttr = putStrLn . printAttributes |
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
32 |
29d0f605efa9
add updateRootNodeWith
Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
parents:
9
diff
changeset
|
33 |
7 | 34 {- |
35 ghci> :l test.hs | |
36 ghci> y <- tree | |
37 ghci> putStrLn $ printAttributes y | |
38 ghci> putStrLn $ drawNode y | |
39 -} |