#Kabopan - Readable Algorithms. Public Domain, 2007-2009 from kbp.types import ( \ sub_string, add_string, Str, List, Byte, Dword, Word, Qword, Oword, DQword) assert sub_string("abc", "aBc") == "_B_" assert add_string("abc", "_B_") == "aBc" s = Str("abcdefghij") assert [ s, s << 1, s >> 1, (s << 1) >> 1, s << 2, s << 3, s << 4] == \ ['abcdefghij', 'bcdefghija', 'jabcdefghi', 'abcdefghij', 'cdefghijab', 'defghijabc', 'efghijabcd'] assert s.setstart("d") == "defghijabc" s = Str('abcaba') assert s.indexes("a") == [0, 3, 5] assert s.indexes("d") == [] s = Str("abcdefghij") import pprint assert [s.insert("1", 2), s.insert("12", 2), s.overwrite("1", 2), s.overwrite("12", 2)] == \ ['ab1cdefghij', 'ab12cdefghij', 'ab1defghij', 'ab12efghij'] assert [s.splitblock(2), s.splitblock(3)] == [['ab', 'cd', 'ef', 'gh', 'ij'], ['abc', 'def', 'ghi', 'j']] assert List([1, 2, 3, 4]) >> 1 == [4, 1, 2, 3] assert List([1, 2, 3, 4]) >> 4 == [1, 2, 3, 4] assert List([1, 2, 3, 4]) << 1 == [2, 3, 4, 1]