# This file is part of NIT ( http://www.nitlanguage.org ). # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. var x :String = new RopeString x = x + "NODE" x = x + "AT" x = x + "TEST" print x var lst = new List[String] lst.push(new RopeString.from("ZZ")) lst.push((lst.last * 5)) lst.push(lst.last.insert_at("AA", 2)) lst.push(lst.last.insert_at("NN", 0)) lst.push(lst.last.insert_at("II", 1)) lst.push(lst.last.insert_at(lst.last, 2)) var ss = lst.last.substring(4,4) print ss ss = ss.as(RopeString).insert_at("DD", 2) print ss ss = ss.insert_at("EE", 0) print ss ss = ss.insert_at("FF", ss.length) print ss ss = ss.to_lower print ss ss = ss.to_upper print ss ss = ss.reversed print ss var atb = new Array[String] var s = new RopeString s = s.prepend(".types").as(RopeString) s = s.prepend("./examples/hello_world.nit".substring(11,11)).as(RopeString) s = s.append(".").as(RopeString) s = s.append("1").as(RopeString) s = s.append(".o").as(RopeString) print s var str = new RopeString.from("now") + " step" + " live..." print str print str.reversed for i in str.chars do printn i printn "\n" for i in [0..str.length[ do printn str.chars[i] printn "\n" var iter = str.chars.iterator for i in [0..str.length[ do assert str.chars[i] == iter.item iter.next end assert "now step live...".hash == str.hash for i in str.chars.iterator_from(8) do printn i printn "\n" for i in str.chars.iterator_from(str.length-1) do printn i printn "\n" for i in str.as(RopeString).reverse_substrings_from(12) do printn i printn "\n" for i in str.chars.reverse_iterator do printn i printn "\n" for i in str.chars.reverse_iterator_from(0) do printn i printn "\n" var str2 = str.as(RopeString).insert_at(str.substring_from(3), 3) print str2 print str2.substring(2,3) for i in lst do print i