Search is not available for this dataset
text stringlengths 75 104k |
|---|
def insert_some(ol,*eles,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
id(ol)
insert_some(ol,5,6,7,8,index=2,mode="original")
ol
id(ol)
####
ol = [1,2,3,4]
id(ol)
new = insert_some(ol,5,6,7,8,index=2)
new
id(ne... |
def insert_many(ol,eles,locs,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4,5]
eles = [7,77,777]
locs = [0,2,4]
id(ol)
new = insert_many(ol,eles,locs)
ol
new
id(new)
####
ol = [1,2,3,4,5]
eles = [7,77,777]
... |
def insert_sections_some(ol,*secs,**kwargs):
'''
ol = initRange(0,20,1)
ol
loc = 6
rslt = insert_sections_some(ol,['a','a','a'],['c','c','c','c'],index=loc)
rslt
####
'''
if('mode' in kwargs):
mode = kwargs["mode"]
else:
mode = "new"
lo... |
def insert_section(ol,sec,loc,**kwargs):
'''
ol = initRange(0,20,1)
ol
loc = 6
sec = ['a','b','c','d']
rslt = insert_section(ol,sec,loc)
rslt
####
'''
if('mode' in kwargs):
mode = kwargs["mode"]
else:
mode = "new"
secs = [sec]
... |
def insert_sections_many(ol,secs,locs,**kwargs):
'''
ol = initRange(0,20,1)
ol
locs = [1,6,14,9]
secs = [
['a','a','a'],
['b','b'],
['c','c','c','c'],
['d','d']
]
rslt = insert_sections_many(ol,secs,locs)
rslt
... |
def reorder_sub(ol,sub):
'''
sub = ['query', 'params', 'fragment', 'path']
ol = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment']
reorder_sub(ol,sub)
'''
def cond_func(ele,ol):
index = ol.index(ele)
return(index)
indexes... |
def sort(ol,**kwargs):
'''
from elist.elist import *
ol = [1,3,4,2]
id(ol)
new = sort(ol)
ol
new
id(ol)
id(new)
####
ol = [1,3,4,2]
id(ol)
rslt = sort(ol,mode="original")
ol
rslt
id(ol)
id... |
def sorted_refer_to(l,referer,reverse=False,**kwargs):
'''
from elist.elist import *
l = ["a","b","c"]
referer = [7,8,6]
sorted_refer_to(l,referer)
{'list': ['c', 'a', 'b'], 'referer': [6, 7, 8]}
l
referer
>>>
'''
if("mode" in kwargs):
... |
def batsorted(referer,*lists,**kwargs):
'''
from elist.elist import *
referer = [4,2,3,1]
l1 = ['a','b','c','d']
l2 = [100,200,300,400]
l3 = ['A','B','A','B']
nl1,nl2,nl3 = batsorted(referer,l1,l2,l3)
nl1
nl2
nl3
nl1,nl2,nl3 = batsorted... |
def sortDictList(dictList,**kwargs):
'''
students = [
{'name':'john','class':'A', 'year':15},
{'name':'jane','class':'B', 'year':12},
{'name':'dave','class':'B', 'year':10}
]
rslt = sortDictList(students,cond_keys=['name','class','year'])
... |
def index_firstnot(ol,value):
'''
from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_firstnot(ol,'a')
####index_firstnot, array_indexnot, indexOfnot are the same
array_indexnot(ol,'a')
indexOfnot(ol,'a')
'''
length = ol.__len__()
for i in range(0,... |
def index_last(ol,value):
'''
from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_last(ol,'a')
####lastIndexOf is the same as index_last
lastIndexOf(ol,'a')
'''
length = ol.__len__()
for i in range(length-1,-1,-1):
if(value == ol[i]):
re... |
def index_lastnot(ol,value):
'''
from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_lastnot(ol,'a')
####lastIndexOfnot is the same as index_lastnot
lastIndexOfnot(ol,'a')
'''
length = ol.__len__()
for i in range(length-1,-1,-1):
if(value == ol[i]):... |
def index_whichnot(ol,value,which):
'''
from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
index_whichnot(ol,'a',0)
index_whichnot(ol,'a',1)
index_whichnot(ol,'a',2)
'''
length = ol.__len__()
seq = -1
for i in range(0,length):
if(value == ol[i]):
... |
def indexes_all(ol,value):
'''
from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_all(ol,'a')
'''
length = ol.__len__()
indexes =[]
for i in range(0,length):
if(value == ol[i]):
indexes.append(i)
else:
pass
return(indexes) |
def indexes_some(ol,value,*seqs):
'''
from elist.elist import *
ol = [1,'a',3,'a',4,'a',5]
indexes_some(ol,'a',0,2)
indexes_some(ol,'a',0,1)
indexes_some(ol,'a',1,2)
indexes_some(ol,'a',3,4)
'''
seqs = list(seqs)
length = ol.__len__()
indexes =[]
s... |
def first_continuous_indexesnot_slice(ol,value):
'''
from elist.elist import *
ol = ["a",0,1,"a","a",2,3,"a",4,"a","a","a",5]
first_continuous_indexesnot_slice(ol,"a")
'''
length = ol.__len__()
begin = None
slice = []
for i in range(0,length):
if(not(ol[i]==value)... |
def last_continuous_indexes_slice(ol,value):
'''
from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
last_continuous_indexes_slice(ol,"a")
'''
length = ol.__len__()
end = None
slice = []
for i in range(length-1,-1,-1):
if(ol[i]==value):
... |
def which_continuous_indexes_slice(ol,value,which):
'''
from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
which_continuous_indexes_slice(ol,"a",0)
which_continuous_indexes_slice(ol,"a",1)
which_continuous_indexes_slice(ol,"a",2)
which_continuous_index... |
def seqs_continuous_indexesnot_slices(ol,value,seqs):
'''
from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
seqs_continuous_indexesnot_slices(ol,"a",{0,2})
'''
rslt = []
length = ol.__len__()
seq = -1
cursor = 0
begin = None
slice = []
while(c... |
def all_continuous_indexes_slices(ol,value):
'''
from elist.elist import *
ol = [1,"a","a",2,3,"a",4,"a","a","a",5]
all_continuous_indexes_slices(ol,"a")
'''
rslt = []
length = ol.__len__()
cursor = 0
begin = None
slice = []
while(cursor < length):
cond1 =... |
def shift(ol,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4]
id(ol)
rslt = shift(ol)
pobj(rslt)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4]
id(ol)
rslt = shift(ol,mode="or... |
def pop(ol,index,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4]
id(ol)
rslt = pop(ol,2)
pobj(rslt)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4]
id(ol)
rslt = pop(ol,2,mode... |
def cond_pop(ol,index,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [{'data':0;'type':'number'},{'data':'x';'type':'str'},{'data':'y';'type':'str'},4]
#cond_func_args is a array
def cond_func(index,value,cond_func_args):
'''
... |
def pop_range(ol,start_index,end_index,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_range(ol,2,4)
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
r... |
def pop_indexes(ol,indexes,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,2,3,4,5,6]
id(ol)
rslt = pop_indexes(ol,{0,-3,5})
ol
id(ol)
id(rslt['list'])
####
ol = [1,2,3,4,5,6]
id(ol)
rslt =... |
def remove_first(ol,value,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_first(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
... |
def remove_firstnot(ol,value,**kwargs):
'''
from elist.jprint import pobj
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_firstnot(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)... |
def remove_last(ol,value,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_last(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_last(ol,'a',mode="origi... |
def remove_which(ol,value,which,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a']
id(ol)
new = remove_which(ol,'a',1)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a']
id(ol)
rslt = remove_which(ol,'a',... |
def remove_some(ol,value,*seqs,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_some(ol,'a',1,3)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_s... |
def remove_all(ol,value,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = remove_all(ol,'a')
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt = remove_all(ol,'a',mo... |
def remove_many(ol,values,seqs,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9]
id(ol)
new = remove_many(ol,['a','b'],[1,2])
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'b',5,'a',6,'a',7,'b',8,'b',9]
... |
def cond_remove_all(ol,**kwargs):
'''
from elist.elist import *
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
def afterCH(ele,ch):
cond = (ord(str(ele)) > ord(ch))
return(cond)
new = cond_remove_all(ol,cond_func=afterCH,cond_func_args=['B'])
... |
def cond_remove_some(ol,*some,**kwargs):
'''
from elist.elist import *
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
def afterCH(ele,ch):
cond = (ord(str(ele)) > ord(ch))
return(cond)
new = cond_remove_some(ol,0,2,cond_func=afte... |
def init(len,default_element=None):
'''
from elist.elist import *
init(5)
init(5,"x")
'''
rslt = []
for i in range(0,len):
rslt.append(copy.deepcopy(default_element))
return(rslt) |
def array_from(obj,func,*args):
'''
from elist.elist import *
array_from("abcd",None)
#####
def map_func(ele,x,y):
return(int(ele)+x+y)
array_from("1234",map_func,1000,100)
def map_func(ele):
return(int(ele)*2)
... |
def copy_within(ol,target, start=None, end=None):
'''
from elist.elist import *
ol = [1, 2, 3, 4, 5]
id(ol)
rslt = copyWithin(ol,0,3,4)
rslt
id(rslt)
####
ol = [1, 2, 3, 4, 5]
id(ol)
rslt = copyWithin(ol,0,3)
rslt
id(rsl... |
def reverse(ol,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4]
id(ol)
new = reverse(ol)
ol
new
id(ol)
id(new)
####
ol = [1,2,3,4]
id(ol)
rslt = reverse(ol,mode="original")
ol
rslt
id(ol)
... |
def comprise(list1,list2,**kwargs):
'''
from elist.elist import *
comprise([1,2,3,4,5],[2,3,4],mode="loose")
comprise([1,2,3,4,5],[2,3,4])
comprise([1,2,3,4,5],[2,3,4],mode="strict")
comprise([1,2,3,4,5],[1,2,3,4],mode="strict")
#not recursive ,only one level
... |
def entries(ol):
'''
from elist.elist import *
ol = ['a','b','c']
rslt = entries(ol)
rslt
'''
rslt = []
length = ol.__len__()
for i in range(0,length):
entry = [i,ol[i]]
rslt.append(entry)
return(rslt) |
def splice(ol,start,deleteCount,*eles,**kwargs):
'''
from elist.elist import *
ol = ["angel", "clown", "mandarin", "surgeon"]
id(ol)
new = splice(ol,2,0,"drum")
new
id(new)
####
ol = ["angel", "clown", "mandarin", "surgeon"]
id(ol)
new ... |
def slice(ol,start,end=None,**kwargs):
'''
from elist.elist import *
ol = [1,2,3,4,5]
id(ol)
new = slice(ol,2,4)
new
id(new)
####
id(ol)
rslt = slice(ol,1,-2,mode="original")
rslt
id(rslt)
'''
if('mode' in kwargs):
... |
def join(ol,separator=","):
'''
from elist.elist import *
ol = [1,2,3,4]
join(ol,separator="-")
'''
if(ol.__len__() == 0):
return("")
else:
pass
cond = (type(ol[0])==type(b''))
if(cond):
rslt = b''
else:
rslt =""
length = ol.__len__... |
def join2(ol,*sps):
'''
from elist.elist import *
ol = [1,2,3,4]
join2(ol,"-","+","*")
'''
rslt =""
length = ol.__len__()
for i in range(0,length-1):
rslt = rslt + str(ol[i]) + sps[i]
rslt = rslt + str(ol[length - 1])
return(rslt) |
def htmljoin(ol,sp,**kwargs):
'''
ol = [1,2,3,4]
htmljoin(ol,"option",outer="select")
'''
if('outer' in kwargs):
outer = kwargs['outer']
else:
outer = ""
if(outer):
head = "<" + outer + ">"
tail = "</" + outer + ">"
else:
head = ""... |
def uniqualize(l,**kwargs):
'''
from elist.elist import *
l = [1, 2, 2]
new = uniqualize(l)
new
id(l)
id(new)
####
l = [1, 2, 2]
rslt = uniqualize(l,mode="original")
rslt
id(l)
id(rslt)
'''
if('mode' in kwargs):
... |
def cond_uniqualize(l,**kwargs):
'''
from elist.elist import *
l = [('BIGipServer', 'rd100'), ('TS013d8ed5', '00A0'), ('BIGipServer', 'rd200'), ('TS013d8ed5', '00B0'), ('SID', '1'), ('SID', '2')]
def cond_func(ele,*args):
cond = ele[0]
return(cond)
... |
def interleave(*arrays,**kwargs):
'''
arr1 = [1,2,3,4]
arr2 = ['a','b','c','d']
arr3 = ['@','#','%','*']
interleave(arr1,arr2,arr3)
'''
anum = arrays.__len__()
rslt = []
length = arrays[0].__len__()
for j in range(0,length):
for i in range(0,anum):
... |
def deinterleave(ol,gnum):
'''
ol = [1, 2, 3, 4, 5, 6, 7, 8, 9]
deinterleave(ol,3)
'''
def test_func(ele,index,interval,which):
cond= (index % interval == which)
return(cond)
rslt = []
for i in range(0,gnum):
arr = cond_select_all2(ol,cond_func = test... |
def for_each(ol,test_func,*args):
'''
from elist.elist import *
def show_func(ele):
print("<{0}>".format(ele))
ol = [1,2,3,4]
for_each(ol,show_func)
####forEach is the same as for_each
####forEach have no return value
'''
rslt = (... |
def loose_in(pl,k):
'''
pl = ['bcd','xabcxx','x','y']
loose_in(pl,'abc')
'''
cond = some(pl,lambda ele:(k in ele))['cond']
return(cond) |
def select_loose_in(pl,k):
'''
pl = ['bcd','xabcxx','x','y']
select_loose_in(pl,'abc')
'''
def cond_func(ele,index,k):
if(type(ele) == type([])):
cond = loose_in(ele,k)
else:
cond = (k in ele)
return(cond)
arr = cond_select_values_all2(pl,c... |
def select_strict_in(pl,k):
'''
pl = ['bcd','xabcxx','x','y']
select_strict_in(pl,'abc')
'''
def cond_func(ele,index,k):
if(type(ele) == type([])):
cond = (k in ele)
else:
cond = (k == ele)
return(cond)
arr = cond_select_values_all2(pl,cond... |
def regex_in(pl,regex):
'''
regex = re.compile("^[a-z]+$")
pl = ['b1c3d','xab15cxx','1x','y2']
regex_in(pl,regex)
regex = re.compile("^[0-9a-z]+$")
pl = ['b1c3d','xab15cxx','1x','y2']
regex_in(pl,regex)
'''
def cond_func(ele,regex):
m... |
def select_regex_in(pl,regex):
'''
regex = re.compile("^x.*x$")
pl = ['bcd','xabcxx','xx','y']
select_regex_in(pl,'abc')
'''
def cond_func(ele,index,regex):
if(type(ele)==type([])):
cond = regex_in(ele,regex)
else:
m = regex.search(ele)
... |
def some(ol,test_func,*args):
'''
from elist.elist import *
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4]
some(ol,test_func,3)
ol = [1,2,1,3]
some(ol,test_func,3)
'''
rslt = {'cond':False,'index':N... |
def fill(ol,value,start=None, end=None,**kwargs):
'''
from elist.elist import *
ol = [1, 2, 3,4,5]
id(ol)
rslt = fill(ol,4)
rslt
id(rslt)
####
ol = [1, 2, 3,4,5]
id(ol)
rslt = fill(ol,4,1)
rslt
id(rslt)
####
... |
def filter(ol,test_func,*args,**kwargs):
'''
from elist.elist import *
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4]
id(ol)
new = filter(ol,test_func,3)
new
id(new)
#####
ol = [10,20,30,40]
... |
def find_last(ol,test_func,*args):
'''
from elist.elist import *
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4]
last = find_last(ol,test_func,3)
last
#####
ol = [10,20,30,40]
last = find_last(ol,test... |
def find_which(ol,which,test_func,*args):
'''
from elist.elist import *
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4,5,6,7]
last = find_which(ol,0,test_func,3)
last
last = find_which(ol,2,test_func,3)
last
... |
def find_seqs(ol,seqs,test_func,*args):
'''
from elist.elist import *
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4,5,6,7]
some = find_seqs(ol,[0,3],test_func,3)
some
some = find_some(ol,[0,1,2],test_func,3)
... |
def find_allnot(ol,test_func,*args):
'''
from elist.elist import *
from elist.jprint import pobj
def test_func(ele,x):
cond = (ele > x)
return(cond)
ol = [1,2,3,4,5,6,7]
rslt = find_allnot(ol,test_func,3)
pobj(rslt)
'''
rslt =[... |
def reduce_left(ol,callback,initialValue):
'''
from elist.elist import *
def callback(accumulator,currentValue):
accumulator.append(currentValue[0])
accumulator.append(currentValue[1])
return(accumulator)
ol = [(1,2),("a","b"),("x","y")]
r... |
def diff_indexes(l1,l2):
'''
from elist.elist import *
l1 = [1,2,3,5]
l2 = [0,2,3,4]
diff_indexes(l1,l2)
'''
rslt = []
for i in range(0,l1.__len__()):
if(l1[i]!=l2[i]):
rslt.append(i)
return(rslt) |
def diff_values(l1,l2):
'''
from elist.elist import *
l1 = [1,2,3,5]
l2 = [0,2,3,4]
diff_values(l1,l2)
'''
rslt = []
for i in range(0,l1.__len__()):
if(l1[i]!=l2[i]):
rslt.append(l1[i])
return(rslt) |
def same_indexes(l1,l2):
'''
from elist.elist import *
l1 = [1,2,3,5]
l2 = [0,2,3,4]
same_indexes(l1,l2)
'''
rslt = []
for i in range(0,l1.__len__()):
if(l1[i]==l2[i]):
rslt.append(i)
return(rslt) |
def same_values(l1,l2):
'''
from elist.elist import *
l1 = [1,2,3,5]
l2 = [0,2,3,4]
same_values(l1,l2)
'''
rslt = []
for i in range(0,l1.__len__()):
if(l1[i]==l2[i]):
rslt.append(l1[i])
return(rslt) |
def value_indexes_mapping(l):
'''
from elist.elist import *
from elist.jprint import pobj
l = ['a','b','b','a','c','b']
desc = value_indexes_mapping(l)
pobj(desc)
'''
pt = copy.deepcopy(l)
desc = {}
vset = set({})
for v in pt:
vset.add(v)
for v... |
def cond_value_indexes_mapping(l,**kwargs):
'''
from elist.elist import *
l = [('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('BIGipServer', 'rd19'), ('TS013d8ed5', '0105b6b0'), ('SID', '1'), ('SID', '2')]
def cond_func(ele,*args):
cond = ele[0]
return... |
def getitem_via_pathlist(ol,pathlist):
'''
from elist.elist import *
y = ['a',['b',["bb"]],'c']
y[1][1]
getitem_via_pathlist(y,[1,1])
'''
this = ol
for i in range(0,pathlist.__len__()):
key = pathlist[i]
this = this.__getitem__(key)
return(this) |
def getitem_via_sibseqs(ol,*sibseqs):
'''
from elist.elist import *
y = ['a',['b',["bb"]],'c']
y[1][1]
getitem_via_sibseqs(y,1,1)
'''
pathlist = list(sibseqs)
this = ol
for i in range(0,pathlist.__len__()):
key = pathlist[i]
this = this.__getitem__(key... |
def setitem_via_pathlist(ol,value,pathlist):
'''
from elist.elist import *
y = ['a',['b',["bb"]],'c']
y[1][1]
setitem_via_pathlist(y,"500",[1,1])
y
'''
this = ol
for i in range(0,pathlist.__len__()-1):
key = pathlist[i]
this = this.__getitem__(key)... |
def setitem_via_sibseqs(ol,value,*sibseqs):
'''
from elist.elist import *
y = ['a',['b',["bb"]],'c']
y[1][1]
setitem_via_sibseqs(y,"500",1,1)
y
'''
this = ol
pathlist = list(sibseqs)
for i in range(0,pathlist.__len__()-1):
key = pathlist[i]
thi... |
def delitem_via_pathlist(ol,pathlist):
'''
from elist.elist import *
y = ['a',['b',["bb"]],'c']
y[1][1]
delitem_via_pathlist(y,[1,1])
y
'''
this = ol
for i in range(0,pathlist.__len__()-1):
key = pathlist[i]
this = this.__getitem__(key)
this.__... |
def delitem_via_sibseqs(ol,*sibseqs):
'''
from elist.elist import *
y = ['a',['b',["bb"]],'c']
y[1][1]
delitem_via_sibseqs(y,1,1)
y
'''
pathlist = list(sibseqs)
this = ol
for i in range(0,pathlist.__len__()-1):
key = pathlist[i]
this = this.__g... |
def replace_seqs(ol,value,indexes,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = replace_seqs(ol,'AAA',[1,3,7])
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt ... |
def replace_some(ol,value,*indexes,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = replace_some(ol,'AAA',1,3,7)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
rslt =... |
def replace_value_seqs(ol,src_value,dst_value,seqs,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = replace_value_seqs(ol,'a','AAA',[0,1])
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
... |
def replace_value_some(ol,src_value,dst_value,*seqs,**kwargs):
'''
from elist.elist import *
ol = [1,'a',3,'a',5,'a',6,'a']
id(ol)
new = replace_value_some(ol,'a','AAA',0,1)
ol
new
id(ol)
id(new)
####
ol = [1,'a',3,'a',5,'a',6,'a']
... |
def cond_replace_value_some(ol,dst_value,*some,**kwargs):
'''
from elist.elist import *
ol = [1,'X',3,'b',5,'c',6,'A',7,'b',8,'B',9]
id(ol)
def afterCH(ele,ch):
cond = (ord(str(ele)) > ord(ch))
return(cond)
new = cond_replace_value_some(ol,"RE... |
def rangize(break_points,length):
'''
break_points = [1,3,9,12,-2]
length = 15
secs = rangize(break_points,length)
forEach(secs,print)
'''
bps = array_map(break_points,uniform_index,length)
bps.sort()
bps = prepend(bps,0)
bps = append(bps,length)
bps = uniqual... |
def rangize_supplement(spans,lngth):
'''
spans = [(0, 3), (4, 7), (8, 10), (11, 12), (13, 16), (17, 20)]
rangize_supplement(spans,24)
'''
rslt = []
si = 0
ei = spans[0][0]
if(si == ei):
pass
else:
rslt.append((si,ei))
prev_ei = spans[0][1]
for... |
def range_compress(ol):
'''
#only support sorted-ints or sorted-ascii
l = [1,5,6,7,8,13,14,18,30,31,32,33,34]
range_compress(l)
l = [1,5,6,7,8,13,14,18,30,31,32,33,34,40]
range_compress(l)
l = ['a','b','c','d','j','k','l','m','n','u','y','z']
range_compress(l)... |
def range_decompress(cl):
'''
#only support sorted-ints or sorted-ascii
cl = [1, (5, 8), (13, 14), 18, (30, 34)]
range_decompress(cl)
cl = [1, (5, 8), (13, 14), 18, (30, 34), 40]
range_decompress(cl)
cl = [('a', 'd'), ('j', 'n'), 'u', ('y', 'z')]
range_decompr... |
def broken_seqs(ol,break_points):
'''
ol = initRange(0,20,1)
ol
break_points = [1,6,14,9]
secs = broken_seqs(ol,break_points)
forEach(secs,print)
'''
bps = list(break_points)
length = ol.__len__()
rgs = rangize(bps,length)
rslt = []
for i in range(0,rg... |
def brkl2kvlist(arr,interval,sub_pos=1,**kwargs):
'''
arr = ["color1","r1","g1","b1","a1","color2","r2","g2","b2","a2"]
brkl2kvlist(arr,5)
(['color1', 'color2'], [['r1', 'g1', 'b1', 'a1'], ['r2', 'g2', 'b2', 'a2']])
brkl2kvlist(arr,5,2)
([['color1', 'r1'], ['color2', 'r2']], ... |
def divide(ol,interval):
'''
ol = elel.initRange(0,20,1)
interval = 3
rslt = elel.divide(ol,interval)
rslt
rslt = elel.divide(ol,4)
rslt
'''
length = ol.__len__()
seqs = initRange(0,length,interval)
rslt = broken_seqs(ol,seqs)
return(rslt) |
def split(ol,value,**kwargs):
'''
ol = ['a',1,'a',2,'a',3,'a',4,'a']
split(ol,'a')
split(ol,'a',whiches=[0])
split(ol,'a',whiches=[1])
split(ol,'a',whiches=[2])
split(ol,'a',whiches=[0,2])
ol = [1,'a',2,'a',3,'a',4]
split(ol,'a')
split('x=bcdse... |
def where(ol,value):
'''
ol = [0, 4, 6, 8, 10, 14]
where(ol,-1)
where(ol,1)
where(ol,2)
where(ol,3)
where(ol,4)
where(ol,9)
where(ol,14)
where(ol,17)
'''
si = None
ei = None
for i in range(0,ol.__len__()):
ele = ol[i]
... |
def value_interval(ol,value):
'''
ol = [0, 4, 6, 8, 10, 14]
value_interval(ol,-1)
value_interval(ol,1)
value_interval(ol,2)
value_interval(ol,3)
value_interval(ol,4)
value_interval(ol,9)
value_interval(ol,14)
value_interval(ol,17)
'''
s... |
def rand_sub(arr,*args,**kwargs):
'''
arr = ['scheme', 'username', 'password', 'hostname', 'port', 'path', 'params', 'query', 'fragment']
rand_sub(arr,3)
rand_sub(arr,3)
rand_sub(arr,3)
rand_sub(arr)
rand_sub(arr)
rand_sub(arr)
'''
arr = copy.deepcopy(... |
def is_leaf(obj):
'''
the below is for nested-list
any type is not list will be treated as a leaf
empty list will be treated as a leaf
from elist.elist import *
is_leaf(1)
is_leaf([1,2,3])
is_leaf([])
'''
if(is_list(obj)):
length = obj.__len__(... |
def new_ele_description(**kwargs):
'''
from elist.elist import *
from elist.jprint import pobj
root_desc = new_ele_description(leaf=False,depth=0,breadth_path=[],path=[],parent_path=[],parent_breadth_path=[])
pobj(root_desc)
#None means not handled
'''
desc = {
... |
def init_desc_matrix(l):
'''
from elist.elist import *
from elist.jprint import pobj
l = [1,[4],2,[3,[5,6]]]
desc_matrix = init_desc_matrix(l)
pobj(desc_matrix)
'''
leaf = is_leaf(l)
root_desc = new_ele_description(leaf=leaf,depth=0,breadth_path=[],path=[],parent_... |
def _init_unhandled(l,inited_matrix):
'''
from elist.elist import *
from elist.jprint import pobj
l = [1,[4],2,[3,[5,6]]]
desc_matrix = init_desc_matrix(l)
unhandled = _init_unhandled(l,desc_matrix)
unhandled_data = unhandled['data']
unhandled_desc = unhandled... |
def update_desc_lsib_path(desc):
'''
leftSibling
previousSibling
leftSib
prevSib
lsib
psib
have the same parent,and on the left
'''
if(desc['sib_seq']>0):
lsib_path = copy.deepcopy(desc['path'])
lsib_path[-1] = desc['sib_seq']-... |
def update_desc_rsib_path(desc,sibs_len):
'''
rightSibling
nextSibling
rightSib
nextSib
rsib
nsib
have the same parent,and on the right
'''
if(desc['sib_seq']<(sibs_len-1)):
rsib_path = copy.deepcopy(desc['path'])
rsib_path[-1]... |
def update_desc_lcin_path(desc,pdesc_level):
'''
leftCousin
previousCousin
leftCin
prevCin
lcin
pcin
parents are neighbors,and on the left
'''
parent_breadth = desc['parent_breadth_path'][-1]
if(desc['sib_seq']==0):
if(parent_bread... |
def update_desc_rcin_path(desc,sibs_len,pdesc_level):
'''
rightCousin
nextCousin
rightCin
nextCin
rcin
ncin
parents are neighbors,and on the right
'''
psibs_len = pdesc_level.__len__()
parent_breadth = desc['parent_breadth_path'][-1]
i... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.