1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 intrude import standard
::ropes
18 # Force building a Rope
19 redef fun maxlen
: Int do return once
2
21 var x
:String = new Concat("NODE", "AT")
27 var lst
= new List[String]
31 lst
.push
((lst
.last
* 5))
33 lst
.push
(lst
.last
.insert_at
("AA", 2))
35 lst
.push
(lst
.last
.insert_at
("NN", 0))
37 lst
.push
(lst
.last
.insert_at
("II", 1))
39 lst
.push
(lst
.last
.insert_at
(lst
.last
, 2))
41 var ss
= lst
.last
.substring
(4,4)
45 ss
= ss
.insert_at
("DD", 2)
49 ss
= ss
.insert_at
("EE", 0)
53 ss
= ss
.insert_at
("FF", ss
.length
)
69 var atb
= new Array[String]
71 var s
: String = "./examples/hello_world.nit".substring
(11,11) + ".types"
78 var str
= "now" + " step" + " live..."
84 for i
in str
.chars
do printn i
87 for i
in [0..str
.length
[ do printn str
.chars
[i
]
90 var iter
= str
.chars
.iterator
91 for i
in [0..str
.length
[ do
92 assert str
.chars
[i
] == iter
.item
96 assert "now step live...".hash
== str
.hash
98 for i
in str
.chars
.iterator_from
(8) do printn i
101 for i
in str
.chars
.iterator_from
(str
.length-1
) do printn i
104 for i
in str
.chars
.reverse_iterator
do printn i
107 for i
in str
.chars
.reverse_iterator_from
(0) do printn i
110 var str2
= str
.insert_at
(str
.substring_from
(3), 3)
114 print str2
.substring
(2,3)
116 for i
in lst
do print i