Last active
March 24, 2024 10:03
-
-
Save lastforkbender/c73f56a5fd1c6c4cd2f43e141f55642d to your computer and use it in GitHub Desktop.
DUN3.py is a regressive random complex lambda generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ===__=_==_==____====_=======___====__=====_==_=_= | |
| # =_==_====_===_====___=_____======__====_== | |
| # =__===_==_______========_=_=====___==___= | |
| # DUN3 LAMBDA GENERATOR v1.00.83 | |
| # =_===_=___====___====_==_==__==__==__= | |
| # =__=====____===_==_=======___=====_==_= | |
| # ===__====_=_==____====__=====___====_=_== | |
| #'________________________________________________________________________________' | |
| # This module builds random complex lambdas, test them and stores them. The | |
| # goal, have a very secure communication protocol between two vfs systems in | |
| # that the lambda functions self-encrypt themselves between send & read. Where | |
| # lambda functions as a resolved segment reads, a closed others as same send. | |
| # A basis is assumed the lambda functions are of specific grouping, include listed | |
| # unique data and all lambda string functions of one shared common param each. | |
| # This would include uses with hybrid quantum computing, whereas sent & read | |
| # data can take on multiple forms of return on one send; lambda functions allow. | |
| # rcttcr5@gmail.com | |
| #'________________________________________________________________________________' | |
| from collections import namedtuple as nt | |
| import concurrent.futures | |
| import functools as ft | |
| import random as rm | |
| import inspect as isc | |
| import socket | |
| import time | |
| import ast | |
| import re | |
| #'________________________________________________________________________________' | |
| class DUN3: | |
| # (The default is us, our perspectives; and a ultimate truth being earth does not need any of us. One that lies has lied, yet one that lies to there ownself is a origin of any evil possible.) | |
| __slots__ = ('_lmbFncNm','_lmbFncHdr','_lmbFncBdy','_lmbFncPrms','_lmbCndPos','_lmbSgnCds','_lmbDun3Reg1','_lmbDun3Reg2','_lmbDun3Reg3','_sp1ce','_twr','_twi','_drd','_vLstFull','_vLstAbr','_rpNtr','_rNtrA','_rNtrB','_rNtrC','_rLstA','_rLstB','_dEvalA','_dEvalB','_dEvalC','_dEvalD','_dTplA','_dLstA','_dStrA','_dStrB','_srLstA','_rStrA','_rStrB','_rStrC','_rStrD','_sStrA','_sStrB','_rIntA','_rIntB','_rIntC','_rIntD','_srIntA') | |
| def __init__(self,_lmbFncNm,_lmbFncHdr,_lmbFncBdy,_lmbFncPrms,_lmbCndPos,_lmbSgnCds,_lmbDun3Reg1,_lmbDun3Reg2,_lmbDun3Reg3,_twr,_twi,_drd,_vLstFull,_vLstAbr,_sp1ce,_rpNtr,_rNtrA,_rNtrB,_rNtrC,_rLstA,_rLstB,_dEvalA,_dEvalB,_dEvalC,_dEvalD,_dTplA,_dLstA,_dStrA,_dStrB,_srLstA,_rStrA,_rStrB,_rStrC,_rStrD,_sStrA,_sStrB,_rIntA,_rIntB,_rIntC,_rIntD,_srIntA): | |
| self._lmbFncNm = _lmbFncNm | |
| self._lmbFncHdr = _lmbFncHdr | |
| self._lmbFncBdy = _lmbFncBdy | |
| self._lmbFncPrms = _lmbFncPrms | |
| self._lmbCndPos = _lmbCndPos | |
| self._lmbSgnCds = _lmbSgnCds | |
| self._lmbDun3Reg1 = _lmbDun3Reg1 | |
| self._lmbDun3Reg2 = _lmbDun3Reg2 | |
| self._lmbDun3Reg3 = _lmbDun3Reg3 | |
| self._drd = _drd | |
| self._vLstFull = ['constant','count','pivot','index','length','shift','range','position','string','cast','fraction','random','bytes','math','quantum','xor','max','min','pattern','lambda'] | |
| self._vLstAbr = ['cnst','cnt','pvt','idx','len','shf','rng','pos','str','cst','frc','rdm','byt','mth','qtm','xor','max','min','ptn','lmb'] | |
| self._twr = _twr | |
| self._twi = _twi | |
| self._sp1ce = _sp1ce | |
| self._rpNtr = _rpNtr | |
| self._rNtrA = _rNtrA | |
| self._rNtrB = _rNtrB | |
| self._rNtrC = _rNtrC | |
| self._rLstA = _rLstA | |
| self._rLstB = _rLstB | |
| self._dEvalA = _dEvalA | |
| self._dEvalB = _dEvalB | |
| self._dEvalC = _dEvalC | |
| self._dEvalD = _dEvalD | |
| self._dTplA = _dTplA | |
| self._dLstA = _dLstA | |
| self._dStrA = _dStrA | |
| self._dStrB = _dStrB | |
| self._srLstA = _srLstA | |
| self._rStrA = _rStrA | |
| self._rStrB = _rStrB | |
| self._rStrC = _rStrC | |
| self._rStrD = _rStrD | |
| self._sStrA = _sStrA | |
| self._sStrB = _sStrB | |
| self._rIntA = _rIntA | |
| self._rIntB = _rIntB | |
| self._rIntC = _rIntC | |
| self._rIntD = _rIntD | |
| self._srIntA = _srIntA | |
| #'_______________________________________________________________________________' | |
| # LAMBDA-X REGRESSIVE FUNCTIONS | |
| #'_______________________________________________________________________________' | |
| def lxr_constant(self, rtrn): | |
| cnstLst = [' |if| #x < @cnst: ',' |if| #x <= @cnst: ',' |if| #x > @cnst: ',' |if| #x >= @cnst: ',' |for| #x < @cnst: ',' |for| #x in @cnst: ',' #x |for| #x in @cnst: ',' |if| #x == @cnst: ',' |else| #x == @cnst: ',' |if| #x != @cnst: ',' |else| #x != @cnst: '] | |
| if not rtrn: self._lmbFncBdy.append(cnstLst[rm.randint(0,len(cnstLst)-1)]) | |
| else: | |
| return cnstLst[rm.randint(0,len(cnstLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_count(self, rtrn): | |
| cntLst = [' |for| @cnt in range(#x): ',' @cnt |for| @cnt in range(#x): ',' |for| @cnt in #x: ',' @cnt |for| @cnt in #x: ',' |if| @cnt in #x: ',' |if| @cnt < #x: ',' |if| @cnt > #x: ',' |if| @cnt == #x: ',' |else| #x == @cnt: ', ' |else| #x > @cnt: ', ' |else| #x < @cnt: ',' |else| @cnt in #x: '] | |
| if not rtrn: self._lmbFncBdy.append(cntLst[rm.randint(0,len(cntLst)-1)]) | |
| else: | |
| return cntLst[rm.randint(0,len(cntLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_pivot(self, rtrn): | |
| pvtLst = [' ((@pvt*@pvt)/#x) ',' (@pvt*@pvt-#x) ',' (#x+@pvt+@pvt) ',' (#x-@pvt) ',' (@pvt+#x) ',' (#x*@pvt) ',' ((@pvt+#x)/#x) ',' ((#x*@pvt)/#x) ',' ((#x*@pvt)//@pvt) ',' ((@pvt+#x)//#x) '] | |
| if not rtrn: self._lmbFncBdy.append(pvtLst[rm.randint(0,len(pvtLst)-1)]) | |
| else: | |
| return pvtLst[rm.randint(0,len(pvtLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_index(self, rtrn): | |
| idxLst = [' #l[@idx] ',' #l[@idx-#x] ',' #l[@idx+#x] ',' #l[len(#l)-@idx] ',' #l[len(#l)+@idx] '] | |
| if not rtrn: self._lmbFncBdy.append(idxLst[rm.randint(0,len(idxLst)-1)]) | |
| else: | |
| return idxLst[rm.randint(0,len(idxLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_length(self, rtrn): | |
| lenLst = [' @len(#l) ',' @len(#s) ',' @len(#l)-#x ',' @len(#s)-#x ',' @len(#l)+#x ',' @len(#s)+#x ',' @len(#l)*#x ',' @len(#s)*#x '] | |
| if not rtrn: self._lmbFncBdy.append(lenLst[rm.randint(0,len(lenLst)-1)]) | |
| else: | |
| return lenLst[rm.randint(0,len(lenLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_shift(self, rtrn): | |
| shfLst = [' #b<<@shf ',' #b>>@shf ',' #b*(#x**@shf) ',' #b//(#x**@shf) '] | |
| if not rtrn: self._lmbFncBdy.append(shfLst[rm.randint(0,len(shfLst)-1)]) | |
| else: | |
| return shfLst[rm.randint(0,len(shfLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_range(self, rtrn): | |
| rngLst = [' |for| #x in range(#x, @rng, #x): ',' |for| #x in range(@rng, #x, #x): ',' |for| #x, @rng in enumerate(@rng): '] | |
| if not rtrn: self._lmbFncBdy.append(rngLst[rm.randint(0,len(rngLst)-1)]) | |
| else: | |
| return rngLst[rm.randint(0,len(rngLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_position(self, rtrn): | |
| posLst = [' |if| any(#x > @pos |for| #x in #l): ',' |else| any(#x > @pos |for| #x in #l): ',' |if| any(#x < @pos |for| #x in #l): ',' |else| any(#x < @pos |for| #x in #l): ',' |if| any(#x == @pos |for| #x in #l): ',' |else| any(#x == @pos |for| #x in #l): '] | |
| if not rtrn: self._lmbFncBdy.append(posLst[rm.randint(0,len(posLst)-1)]) | |
| else: | |
| return posLst[rm.randint(0,len(posLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_string(self, rtrn): | |
| strLst = [' ~@str+#s ',' ~^@str+str(#x) ',' ~^@str+str(#b) ','~^@str(#x) ',' ~^@str(#b) ',' ~@str[#x:#x] ',' ~@str[::-1]'] | |
| if not rtrn: self._lmbFncBdy.append(strLst[rm.randint(0,len(strLst)-1)]) | |
| else: | |
| return strLst[rm.randint(0,len(strLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_cast(self, rtrn): | |
| cstLst = [' @cst(#x) ',' @cst(#f) ',' @cst(#s) ',' @cst(#b) ',' @cst(range(#x)) '] | |
| if not rtrn: self._lmbFncBdy.append(cstLst[rm.randint(0,len(cstLst)-1)]) | |
| else: | |
| return cstLst[rm.randint(0,len(cstLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_fraction(self, rtrn): | |
| # PARSE-INDENTIFIER = if has list (...*<>...) else (...<>...) | |
| frcLst = [' ...Decimal(#x)... ', ' ...*Decimal(round(sum(#l)/len(#l), #x))... ', ' ...*Decimal(round(sum(Decimal(round(getcontext().sqrt(#f), #x)) for #f in #l)/len(#l), #x))... ', ' ...(Decimal(len(str(#f))-len(str(#f))) ** #x)... ', ' ...(Decimal(len(str(#f))+len(str(#f))) ** #x)... ', ' ...Decimal(abs(#f-#f))... ', ' ...Decimal(abs(#f+#f))... ', ' ...*[#f for #f in #fl for #f in #fl if != and (#f := Decimal(abs(#f-#f))) > #d]... '] | |
| if not rtrn: self._lmbFncBdy.append(frcLst[rm.randint(0,len(frcLst)-1)]) | |
| else: | |
| return frcLst[rm.randint(0,len(frcLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_random(self, rtrn): | |
| # PARSE-INDENTIFIER = if has list (???*<>???) else (???<>???) | |
| rdmLst = [' ???*[random.randint(#x,#x) for _ in range(#x)]??? ',' ???random.randint(#x,#x)??? ', ' ???*random.randint(#x,len(#l))??? ', ' ???random.randint(#x,len(@str))??? ', ' ???random.randint(#x,@rng)??? ', ' ???random.randint(#x,@len)??? ', ' ???random.randint(#x,@pvt)??? ', ' ???random.randint(#x,@cnst)??? '] | |
| if not rtrn: self._lmbFncBdy.append(rdmLst[rm.randint(0,len(rdmLst)-1)]) | |
| else: | |
| return rdmLst[rm.randint(0,len(rdmLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_bytes(self, rtrn): | |
| # PARSE-INDENTIFIER = if has list (:::*<>:::) else (:::<>:::) | |
| bytLst = [' :::bytes(@shf, ]enc[)::: ', ' :::bytes(@str, ]enc[)::: ', ' :::bytes(@pos, ]enc[)::: ', ' :::*bytes(#x for #x in #l)::: '] | |
| if not rtrn: self._lmbFncBdy.append(bytLst[rm.randint(0,len(bytLst)-1)]) | |
| else: | |
| return bytLst[rm.randint(0,len(bytLst)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_math(self, rtrn, src): | |
| # PARSE-INDENTIFIER = (***<>***) | |
| return self.lxr_math_ext(rtrn, src) | |
| #'_______________________________________________________________________________' | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3(self): | |
| # Main parser. | |
| # normal registers action: lxr_dun3_reg(False,'ins:idx:dat'), @rpNtr must be set first | |
| # Slots In-use: rStrA, dStrA, dStrB, rLstA | |
| print(f'\n{self.fdb(False)}○ DUN3 main parsing method is reached, setting registers structures') | |
| self.rst(False) | |
| self._rLstA = self._lmbFncBdy.split(' ') | |
| self._rLstA = list(filter(lambda _:_.strip(),self._rLstA)) | |
| self.lxr_dun3_reg(True,None) | |
| print(f'{self.fdb(True)}reset of registers finished, setting (Reg1) for vars weighing') | |
| self._rpNtr = '1,1' | |
| self.lxr_dun3_qlt_cntrl(self._lmbFncBdy) | |
| #'=============================================================' | |
| stp = 'raw, preconditional escapes' | |
| qMnPrsrStrt = True | |
| qInsCall = True | |
| qIns = None | |
| qSgn = False | |
| sDiu = True | |
| #'=============================================================' | |
| while True: | |
| if qInsCall == True: | |
| qInsCall = False | |
| print(f'{self.fdb(True)}inserting any special casting/quanity operations to lambda') | |
| if qMnPrsrStrt == True: self._dStrA = self.lxr_dun3_oyster(self._lmbFncBdy) | |
| else: self._dStrA = self.lxr_dun3_oyster(self._dStrA) | |
| if self._dStrA == '!!!': qIns = False | |
| else: qIns = True | |
| if qMnPrsrStrt == True: | |
| # Begin loop methods here: | |
| qMnPrsrStrt == False | |
| self.lxr_dun3_cougar(True) | |
| print(f'{self.fdb(True)}renaming of the lambda parameter variables was applied') | |
| print(f'{self.fdb(True)}...finding new conditional instruction positions for parsing') | |
| if qIns == True: self.lxr_pre_prsr_cnd_ext(self._dStrA) | |
| else: | |
| self.lxr_pre_prsr_cnd_ext(self._lmbFncBdy) | |
| self._dStrA = self._lmbFncBdy | |
| self._rpNtr = '2,1' | |
| self.lxr_dun3_reg(False, f'add:none:{self._dStrA}') | |
| self._lmbFncBdy = None | |
| self._rpNtr = '3,1' | |
| self.lxr_dun3_tower(257, True) | |
| self._rpNtr = '3,2' | |
| if self.lxr_dun3_signature(True,False) == True: qSgn = True | |
| if self.lxr_dun3_signature(False,True) == True: qSgn = True | |
| else: | |
| # Non-begin loop methods here: | |
| pass | |
| #'=============================================================' | |
| if sDiu == True: | |
| sDiu = False | |
| print(f'\n{self.fdb(False)}□ Sending anonymous lambda function data @DUN3.COM') | |
| self.snd(stp, self._dStrA) | |
| #'=============================================================' | |
| #'=============================================================' | |
| qIns = False | |
| break | |
| #'=============================================================' | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_signature(self, forBars, forElse): | |
| # Finds unique coding signatures for insert/eval uses, after a tower method run. | |
| # **** @rpNtr register-pointer must be set before call of this function **** | |
| pcl = [] | |
| if forBars: | |
| print(f'\n{self.fdb(False)}○ Scanning register{self._rpNtr} for any dual for-bar coding signature(s):') | |
| pcl = ['f','o','|','f'] | |
| elif forElse: | |
| print(f'\n{self.fdb(False)}○ Scanning register{self._rpNtr} for any unique for-else coding signature(s)') | |
| pcl = ['f','o','|','e'] | |
| rLen = self.lxr_dun3_reg(False, f'len:none:none') | |
| if rLen > 0: | |
| r = None | |
| rCnt = 0 | |
| prvChr = None | |
| nra = None | |
| for ri in range(rLen): | |
| r = self.lxr_dun3_reg(False, f'rd:{ri}:none') | |
| nra = 1 | |
| prvChr = None | |
| for chr in r: | |
| if nra == 1 and prvChr == pcl[0] and chr == pcl[1]: nra = 2 | |
| elif nra == 2: | |
| if chr == 'r': nra = 3 | |
| else: nra = 1 | |
| elif nra == 3: | |
| if prvChr == pcl[2] and chr == pcl[3]: | |
| rCnt+=1 | |
| if len(r) > 50: | |
| if forBars: print(f'{self.fdb(True)}multiple for-bar code signature found! [{r[:50]}...]') | |
| elif forElse: print(f'{self.fdb(True)}multiple for-else code signature found! [{r[:50]}...]') | |
| else: | |
| if forBars: print(f'{self.fdb(True)}multiple for-bar code signature found! [{r[:len(r)-1]}...]') | |
| elif forElse: print(f'{self.fdb(True)}multiple for-else code signature found! [{r[:len(r)-1]}...]') | |
| if forBars: self._lmbSgnCds.append(f'forbar({self._rpNtr},{ri})') | |
| elif forElse: self._lmbSgnCds.append(f'forelse({self._rpNtr},{ri})') | |
| break | |
| prvChr = chr | |
| if rCnt == 0: | |
| if forBars: | |
| print(f'{self.fdb(True)}no dual for-bar coding signature(s) found @ register{self._rpNtr}') | |
| return False | |
| elif forElse: | |
| print(f'{self.fdb(True)}no for-else coding signature(s) found @ register{self._rpNtr}') | |
| return False | |
| else: | |
| return True | |
| else: | |
| print(f'{self.fdb(True)}no pre-retain coding line(s) present for a signature code scan @ register{self._rpNtr}') | |
| return False | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_tower(self, ttlCmb, efi): | |
| # Adds random unsorted & joined combinations of initial lambda string to register. | |
| # For advanced reg searches, instruction shift learnings and boundary detections. | |
| # **** @rpNtr register-pointer must be set before call of this function **** | |
| print(f'\n{self.fdb(False)}● Adding randomized combos from initial lambda string build to register{self._rpNtr}:') | |
| self._sStrA = self._dStrA.split(' ') | |
| rLen = len(self._sStrA) | |
| r = 0 | |
| while r < rLen: | |
| if self._sStrA[r] == '' or self._sStrA[r] == ' ' or self._sStrA[r] == ' ' or self._sStrA[r] == ' ' or self._sStrA[r] == None: | |
| self._sStrA.pop(r) | |
| if r-1 < 0: r = 0 | |
| else: r-=1 | |
| rLen = len(self._sStrA) | |
| r+=1 | |
| strt = True | |
| dplc = None | |
| for x in range(ttlCmb): | |
| self._sStrB = self.rsl(self._sStrA) | |
| self._sStrB = '÷'.join(self._sStrB) | |
| if strt: | |
| strt = False | |
| self.lxr_dun3_reg(False, f'add:none:{self._sStrB}') | |
| else: | |
| rLen = self.lxr_dun3_reg(False, f'len:none:none') | |
| dplc = False | |
| for d in range(rLen): | |
| if self.lxr_dun3_reg(False, f'rd:{d}:none') == self._sStrB: | |
| dplc = True | |
| break | |
| if not dplc: | |
| self.lxr_dun3_reg(False, f'add:none:{self._sStrB}') | |
| if len(self._sStrB) > 56: print(f'{self.fdb(True)}■ DUN3(register{self._rpNtr}[{x}])="{self._sStrB[:56]}..."') | |
| else: print(f'{self.fdb(True)}■ DUN3(register{self._rpNtr}[{x}])="{self._sStrB[:len(self._sStrB)-1]}..."') | |
| else: print(f'{self.fdb(True)}duplicate combo instruction join was found, not added to register...') | |
| if efi: | |
| print(f'\n{self.fdb(False)}○ Scanning register{self._rpNtr} for unique if-else, if-for or for-if pre-retains:') | |
| rLen = self.lxr_dun3_reg(False, f'len:none:none') | |
| orgP = self._rpNtr | |
| self._rpNtr = self._rpNtr.split(',') | |
| rpNl = f'{self._rpNtr[0]},{int(self._rpNtr[1])+1}' | |
| rAdd = None | |
| rChr = None | |
| rCnt = 0 | |
| for ri in range(rLen): | |
| strt = 1 | |
| dplc = 1 | |
| rChr = None | |
| rAdd = False | |
| self._rpNtr = orgP | |
| r = self.lxr_dun3_reg(False, f'rd:{ri}:none') | |
| for chr in r: | |
| if strt == 1: | |
| if chr == 'f' or chr == 'i': | |
| strt = 2 | |
| self._sStrA = chr | |
| self._sStrB = chr | |
| elif strt == 2: | |
| if self._sStrA == 'i' and chr == 'f': | |
| strt = 3 | |
| self._sStrB = f'{self._sStrB}{chr}' | |
| elif self._sStrA == 'f' and chr == 'o': | |
| strt = 4 | |
| self._sStrB = f'{self._sStrB}{chr}' | |
| else: strt = 1 | |
| elif strt == 3: | |
| if dplc == 1: | |
| if chr == 'e' or chr == 'f' or chr == 'i': | |
| dplc = 2 | |
| rChr = chr | |
| else: self._sStrB = f'{self._sStrB}{chr}' | |
| elif dplc == 2: | |
| if chr == 'l' or chr == 'o' or chr == 'f': | |
| if len(self._sStrB) > 13: | |
| rCnt+=1 | |
| self._rpNtr = rpNl | |
| self._sStrB = self._sStrB.replace('÷',' ') | |
| self.lxr_dun3_reg(False, f'add:none:{self._sStrB}') | |
| if len(self._sStrB) > 50: print(f'{self.fdb(True)}unique "if" encoding found & kept: {self._sStrB[:50]}...') | |
| else: print(f'{self.fdb(True)}unique "if" encoding found & kept: {self._sStrB[:len(self._sStrB)-1]}...') | |
| break | |
| else: | |
| break | |
| else: | |
| dplc = 1 | |
| self._sStrB = f'{self._sStrB}{rChr}{chr}' | |
| elif strt == 4: | |
| if chr == 'r' and dplc == 1: | |
| dplc = 2 | |
| self._sStrB = f'{self._sStrB}{chr}' | |
| elif dplc == 2: | |
| if rChr == 'e' and chr == 'l': rAdd = True | |
| elif rChr == 'i' and chr == 'f': rAdd = True | |
| else: | |
| rChr = chr | |
| self._sStrB = f'{self._sStrB}{chr}' | |
| if rAdd == True: | |
| if len(self._sStrB) > 13: | |
| rCnt+=1 | |
| self._rpNtr = rpNl | |
| self._sStrB = self._sStrB.replace('÷',' ') | |
| self.lxr_dun3_reg(False, f'add:none:{self._sStrB}') | |
| if len(self._sStrB) > 48: print(f'{self.fdb(True)}unique "for" encoding found & kept: {self._sStrB[:48]}...') | |
| else: print(f'{self.fdb(True)}unique "for" encoding found & kept: {self._sStrB[:len(self._sStrB)-1]}...') | |
| break | |
| else: | |
| break | |
| else: | |
| break | |
| if rCnt == 0: print(f'{self.fdb(True)}no unique pre-retain if | for sets found........') | |
| else: print(f'{self.fdb(True)}total unique pre-retain if | for sets found: {rCnt}') | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_cougar(self, bgn): | |
| # Changes general variable type namings to a stronger variable type namings. | |
| rng = None | |
| if bgn: | |
| self._sStrA = re.findall(r'var1.*?\:', self._lmbFncHdr) | |
| self._sStrA = self._sStrA[0].replace(' ','').strip(':').split(',') | |
| pLstCnt = [1 for _ in range(20)] | |
| rng = len(self._lmbFncPrms) | |
| for lp in range(rng): | |
| for x in range(20): | |
| if self._lmbFncPrms[lp] == self._vLstFull[x]: | |
| self._sStrB = f'{self._vLstAbr[x]}_{pLstCnt[x]}' | |
| pLstCnt[x]+=1 | |
| break | |
| self._lmbFncPrms[lp] = self._sStrB | |
| self._sStrA[lp] = self._sStrB | |
| self._sStrB = ', '.join(self._sStrA) | |
| self._lmbFncHdr = f'{self._lmbFncNm} = lambda {self._sStrB}:' | |
| for p1Idx in range(rng): | |
| pass | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_oyster(self, src): | |
| # Finds a single empty quantifier/cast method mark-in and converts it to a mark-in instruction reading. | |
| # **** @lxr_dun3 controls if this function is called or not called **** | |
| oysRpl = 'na' | |
| lst = None | |
| if src.find('^list(') > -1: | |
| oysRpl = '^list(' | |
| lst = ['list(@str)', 'list(@rng)', 'list(@mth)', 'list(@ptn)', 'list(map(@#, @rng(@#)))', 'list(filter(~, @rng(@#)))'] | |
| elif src.find('^int(') > -1: | |
| oysRpl = '^int(' | |
| lst = ['int(`)', '(int(@#), @# ¿ @# ¿ @#) |if| @#.isdigit() |else| ~,'] | |
| elif src.find('^max(') > -1: | |
| oysRpl = '^max(' | |
| lst = ['max(#l)', 'max(#t, key=@lmb #x: ~', 'max(#d, key=@lmb #x: #x[@str]'] | |
| elif src.find('^any(') > -1: | |
| oysRpl = '^any(' | |
| lst = ['any(#x ¿ @# ~ #x ¿ @# |for| #x in @#)', 'any(#l[#x] == @str ¿ #l[#x] == @str |for| #x in @#)', 'any(#d[@str] ¿ #x ~ len(#d[@str]) ¿ #x |for| #x in @#)'] | |
| elif src.find('^all(') > -1: | |
| oysRpl = '^all(' | |
| lst = ['all(#x ¿ @# |for| #x in @#)', 'all(len(@#) ¿ @# |for| #x in @#)'] | |
| elif src.find('^map(') > -1: | |
| oysRpl = '^map(' | |
| lst = ['list(map(lambda #x: ~, [itm |for| sl in #l |for| itm in sl]))', 'dict(map(lambda #x: (#x[0], #x[1]~), #d.items()))', 'set(map(lambda #x: ~, #s))'] | |
| elif src.find('^filter(') > -1: | |
| oysRpl = '^filter(' | |
| lst = ['list(filter(lambda #x: #x ~ ¿ #x, #l))', 'list(filter(lambda #x: #x ¿ @str, @str))', 'list(filter(lambda #x: #x ¿ #x[::-1], @str))', 'list(filter(lambda #x: all(@# ~ @# ¿ #x |for| @# in range(@#, #x)), #l))'] | |
| elif src.find('^bytes(') > -1: | |
| oysRpl = '^bytes(' | |
| lst = ['bytes(`, ]enc[)', '#b.decode(]enc[)', 'bytes.fromhex(@#.encode(]enc[).hex())'] | |
| elif src.find('^min(') > -1: | |
| oysRpl = '^min(' | |
| lst = ['min(#l)', 'min(#d.values())', 'min(filter(lambda #x: #x[0] ¿ @#, #l))', 'min(#t[0] |for| #x in #t)', 'min(#d, key=lambda #x: #x[@#][@#])', 'min(sum(#l, []))'] | |
| elif src.find('^reduce(') > -1: | |
| oysRpl = '^reduce(' | |
| lst = ['reduce(lambda #x, @#: #x ~ @#, #l)', 'reduce(lambda #x, _: #x ~ @#, #l, @cnst)'] | |
| elif src.find('^zip(') > -1: | |
| oysRpl = '^zip(' | |
| lst = ['list(map(lambda #x: list(#x), zip(*#ma)))', 'dict(map(lambda #x: (#x[0], #x[1]), zip(#l, #l)))', 'list(zip(*[#l[#x:] |for| #x in range(@#)]))'] | |
| elif src.find('^str(') > -1: | |
| oysRpl = '^str(' | |
| lst = ['str(`)', 'str(#l)[1:-1].replace(~)', '@str.join(map(str, #ml))'] | |
| elif src.find('^enumerate(') > -1: | |
| oysRpl = '^enumerate(' | |
| lst = ['next(enumerate(#l), (None, None))[#x] |if| @# |else| None', 'sum(@cnst |for| #x, @# in enumerate(#l) in @# ¿ #x)', 'list(enumerate(zip(#l, #l)))', 'list(sum(map(lambda #x: enumerate(#x), #l), ()))', '|for| #x, #x in enumerate(#l):', 'next((#x |for| #x, @# in enumerate(#l) |if| @# ¿ @cnst), None)'] | |
| elif src.find('^join(') > -1: | |
| oysRpl = '^join(' | |
| lst = ['@str.join(map(lambda #x: #x.~, #l))', '@str.join(#l)', '@str.join(map(str, #l))'] | |
| elif src.find('^len(') > -1: | |
| oysRpl = '^len(' | |
| lst = ['len(filter(lambda #x: #x ~ @# ¿ @cnst, #l)))', 'len(list(filter(lambda #x: #x ~ @# ¿ @cnst))) ¿ len(#l)', 'len(list(filter(lambda #x: #x ~ @# ¿ @cnst, #l))) ¿ @#'] | |
| if len(oysRpl) > 2: | |
| sIns = lst[rm.randint(0,len(lst)-1)] | |
| src = src.replace(oysRpl, sIns) | |
| print(f'{self.fdb(True)}special casting/quanity operation was added!') | |
| print(f'{self.fdb(True)} [{sIns}]') | |
| return src | |
| else: | |
| return '!!!' | |
| #'_______________________________________________________________________________' | |
| def lxr_math_ext(self, rtrn, src): | |
| # Adds pre-math routines/functions @ lambda function string or other. | |
| opLst = ['-','+','/','*'] | |
| vrtLst = ['#x','#d','#f','@cnst','@cnt','~'] | |
| mfLst = ['math.sin(','math.cos(','math.tan(','math.floor(','math.ceil(','math.round('] | |
| if isinstance(src, str): | |
| pass | |
| else: | |
| self._sStrA = [] | |
| swE = None | |
| swNE = None | |
| lLen = rm.randint(4,10) | |
| for x in range(lLen): | |
| swE = False | |
| if self.lxr_chc(50,50): | |
| swE = True | |
| self._sStrB = f' ***@cst({vrtLst[rm.randint(0,len(vrtLst)-1)]} = ' | |
| else: | |
| if self.lxr_chc(50,50): | |
| swNE = False | |
| self._sStrB = f' ***@cst({vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}' | |
| else: | |
| swNE = True | |
| self._sStrB = f' ***@cst({mfLst[rm.randint(0,len(mfLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}' | |
| if swE: | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})*** ' | |
| else: | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{mfLst[rm.randint(0,len(mfLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})' | |
| else: self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{mfLst[rm.randint(0,len(mfLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})' | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}+@cnst)*** ' | |
| else: | |
| if self.lxr_chc(50,50): | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}-@cnt)*** ' | |
| else: self._sStrB = f'{self._sStrB}+@cnt)*** ' | |
| else: self._sStrB = f'{self._sStrB})*** ' | |
| else: | |
| if swNE: | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}({vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})))*** ' | |
| else: | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}({mfLst[rm.randint(0,len(mfLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]}){opLst[rm.randint(0,len(opLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})))*** ' | |
| else: | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}({mfLst[rm.randint(0,len(mfLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]}+#x){opLst[rm.randint(0,len(opLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})))*** ' | |
| else: self._sStrB = f'{self._sStrB}({mfLst[rm.randint(0,len(mfLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]}-#x){opLst[rm.randint(0,len(opLst)-1)]}{vrtLst[rm.randint(0,len(vrtLst)-1)]})))*** ' | |
| else: | |
| if self.lxr_chc(50,50): | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}#x)*** ' | |
| else: self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}#x+(~))*** ' | |
| else: | |
| if self.lxr_chc(50,50): self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{mfLst[rm.randint(0,len(mfLst)-1)]}~+{vrtLst[rm.randint(0,len(vrtLst)-1)]}))*** ' | |
| else: self._sStrB = f'{self._sStrB}{vrtLst[rm.randint(0,len(vrtLst)-1)]}{opLst[rm.randint(0,len(opLst)-1)]}{mfLst[rm.randint(0,len(mfLst)-1)]}~-{vrtLst[rm.randint(0,len(vrtLst)-1)]}))*** ' | |
| self._sStrA.append(self._sStrB) | |
| if not rtrn: self._lmbFncBdy.append(self._sStrA[rm.randint(0,len(self._sStrA)-1)]) | |
| else: | |
| return self._sStrA[rm.randint(0,len(self._sStrA)-1)] | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_run(self, lmbFncs): | |
| # Runs four assembled string lambda functions for evals, simultaneously. | |
| cnt = 0 | |
| self._dEvalA = None | |
| self._dEvalB = None | |
| self._dEvalC = None | |
| self._dEvalD = None | |
| self._dLstA = [] | |
| evalCapExcp = [] | |
| with concurrent.futures.ProcessPoolExecutor(max_workers=4) as executor: | |
| futures = {executor.submit(self.lxr_eval, lfStr): lfStr for lfStr in lmbFncs} | |
| for future in concurrent.futures.as_completed(futures): | |
| try: | |
| self._dLstA.append(str(future)) | |
| cnt+=1 | |
| if cnt == 1: self._dEvalA = future.result() | |
| elif cnt == 2: self._dEvalB = future.result() | |
| elif cnt == 3: self._dEvalC = future.result() | |
| elif cnt == 4: self._dEvalD = future.result() | |
| except Exception as run_err: | |
| evalCapExcp.append((futures[future], run_err)) | |
| return evalCapExcp | |
| #'_______________________________________________________________________________' | |
| def lxr_eval(self, lf): | |
| # Evaluates a single lambda function string into dTplA. | |
| lmbFnc = eval(lf) | |
| try: | |
| return lmbFnc(*self._dTplA) | |
| except Exception as eval_err: | |
| return (f'!÷{eval_err}') | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_qlt_cntrl(self, fncBdy): | |
| # Quality pre-stitch weight naming of parameters & other function body vars. | |
| # **** @rpNtr register-pointer must be set before call of this function **** | |
| # Slots In-use: rStrB, rStrC, rStrD, rIntA, rIntB | |
| self._rStrC = 's@nd' | |
| self._rIntA = 0 | |
| varPrm = None | |
| chrSw = None | |
| for chr in fncBdy: | |
| if chr == '#' or chr == '@': | |
| chrSw = True | |
| if chr == '@': varPrm = True | |
| else: varPrm = False | |
| self._rIntB = self._rIntA | |
| self._rStrB = '' | |
| elif chrSw == True: | |
| if self.lxr_chr_chk_prms_vars(chr) == False: | |
| if varPrm == True: | |
| if self.lxr_prms_chk(self._rStrB) == True: | |
| self._rStrD = f'@_{self._rStrB}_{self._rStrC}_{self._rIntB}_{self._rIntA-1}' | |
| else: self._rStrD = f'@_unknown_{self._rStrC}_{self._rIntB}_{self._rIntA-1}' | |
| else: | |
| self._rStrD = f'#_{self._rStrB}_{self._rStrC}_{self._rIntB}_{self._rIntA-1}' | |
| self.lxr_dun3_reg(False,f'add:1:{self._rStrD}') | |
| if varPrm == True: self._rStrC = f'@{self._rStrB}' | |
| else: self._rStrC = f'#{self._rStrB}' | |
| chrSw = False | |
| else: | |
| self._rStrB = f'{self._rStrB}{chr}' | |
| self._rIntA+=1 | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_srch_rplc(self, isRgstr, isRplc, src, srch, srchIdxStrt, rplc, idx): | |
| # Paramount all in one search or/and replace with the registers or a string source. | |
| self._srLstA = [] | |
| rplSw = False | |
| if not isRgstr: | |
| if not isRplc: | |
| # --------------------------------------------Normal Search---------------------------------------------- | |
| # lxr_dun3_srch_rplc(False, False, src, srch, srchIdxStrt, None, None) | |
| # If @srch is not list, srIntA holds result. Else result(s) in srLstA as ['#:#',... | |
| if isinstance(srch, list): | |
| for s in range(len(srch)): | |
| self._srIntA = src.find(srch[s], srchIdxStrt) | |
| if self._srIntA > -1: | |
| self._srLstA.append(f'{self._srIntA}:{self._srIntA+len(srch[s])-1}') | |
| else: self._srLstA.append('!!!') | |
| else: | |
| self._srIntA = src.find(srch, srchIdxStrt) | |
| else: | |
| # ------------------------------------------Replace by Indices------------------------------------------- | |
| # lxr_dun3_srch_rplc(False, True, src, None, None, rplc, idx): | |
| # @rplc & @idx are expected to be both list types equal in substitute(s). | |
| # @idx as list ['#:#',... | |
| if isinstance(rplc, list) and isinstance(idx, list): | |
| for idxStr, rpl in zip(idx, rplc): | |
| crrIdx = list(map(int, idxStr.split(':'))) | |
| chgL = len(rpl)-(crrIdx[1]-crrIdx[0]) | |
| if self._srLstA: | |
| for r in range(len(self._srLstA)): | |
| self._srLstA[r] = (self._srLstA[r][0]+chgL, self._srLstA[r][1]+chgL) | |
| self._srLstA.append((crrIdx[0], crrIdx[0]+len(rpl))) | |
| for rplIdx, rpl in zip(self._srLstA, rplc): | |
| src = src[:rplIdx[0]]+rpl+src[rplIdx[1]:] | |
| self._srLstA = [] | |
| return src | |
| else: | |
| # -------------------------------------------Normal S&R----------------------------------------------- | |
| # lxr_dun3_srch_rplc(False, True, src, srch, srchIdxStrt, rplc, None) | |
| # Replaces @srch up to the length of @rplc list. Any replace, spIce=True. | |
| # srLstA holds the new start & end indices of the replacements as ['#:#',... | |
| if isinstance(rplc, list): rplSw = True | |
| self._sp1ce = False | |
| lstIdx = 0 | |
| while True: | |
| self._srIntA = src.find(srch, srchIdxStrt) | |
| if self._srIntA > -1: | |
| if not self._sp1ce: self._sp1ce = True | |
| if not rplSw: self._srLstA.append(f'{self._srIntA}:{self._srIntA+len(rplc)-1}') | |
| else: self._srLstA.append(f'{self._srIntA}:{self._srIntA+len(rplc[lstIdx])-1}') | |
| if not rplSw: src = self.slc(False, src, self._srIntA, self._srIntA+len(srch), rplc) | |
| else: | |
| src = self.slc(False, src, self._srIntA, self._srIntA+len(srch), rplc[lstIdx]) | |
| if lstIdx+1 > len(rplc)-1: | |
| break | |
| else: lstIdx+=1 | |
| else: | |
| break | |
| if not self._sp1ce: | |
| return '!!!' | |
| else: | |
| return src | |
| else: | |
| # Special algorithm based registers' searches or/and replaces, there must be spIce. | |
| if self._sp1ce: | |
| pass | |
| else: | |
| return False | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_reg(self, spc, cde): | |
| # DUN3 main parser register interactions. | |
| # Slots In-use: rLstB | |
| if spc: | |
| self._lmbDun3Reg1 = nt('REG1','R1 p1 p2 p3 p4') | |
| self._rNtrA = self._lmbDun3Reg1('REG1',[],[],[],[]) | |
| self._lmbDun3Reg2 = nt('REG2','R2 p1 p2 p3 p4') | |
| self._rNtrB = self._lmbDun3Reg2('REG2',[],[],[],[]) | |
| self._lmbDun3Reg3 = nt('REG3','R3 p1 p2 p3 p4') | |
| self._rNtrC = self._lmbDun3Reg3('REG3',[],[],[],[]) | |
| self._rpNtr = '0,0' | |
| else: | |
| if isinstance(cde, str): | |
| self._rLstB = cde.split(':') | |
| if self._rLstB[1] != 'none': | |
| if self._rLstB[0] == 'rd': | |
| return self.lxr_dun3_reg_exc(self._rLstB[0],int(self._rLstB[1]),None) | |
| else: self.lxr_dun3_reg_exc(self._rLstB[0],self._rLstB[1],self._rLstB[2]) | |
| elif self._rLstB[0] == 'len': | |
| return self.lxr_dun3_reg_exc(self._rLstB[0],None,None) | |
| else: self.lxr_dun3_reg_exc(self._rLstB[0],self._rLstB[1],self._rLstB[2]) | |
| else: | |
| pass | |
| #'_______________________________________________________________________________' | |
| def lxr_dun3_reg_exc(self, ins, idx, dat): | |
| # DUN3 main parser register core. | |
| # Slots In-use: N/A | |
| pntrLst = self._rpNtr.split(',') | |
| if pntrLst[0] == '1': | |
| if pntrLst[1] == '1': | |
| if ins == 'rd': | |
| return self._rNtrA.p1[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrA.p1) | |
| elif ins == 'add': self._rNtrA.p1.append(dat) | |
| elif ins == 'rplc': self._rNtrA.p1[idx] = dat | |
| elif ins == 'del': self._rNtrA.p1.pop(idx) | |
| elif pntrLst[1] == '2': | |
| if ins == 'rd': | |
| return self._rNtrA.p2[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrA.p2) | |
| elif ins == 'add': self._rNtrA.p2.append(dat) | |
| elif ins == 'rplc': self._rNtrA.p2[idx] = dat | |
| elif ins == 'del': self._rNtrA.p2.pop(idx) | |
| elif pntrLst[1] == '3': | |
| if ins == 'rd': | |
| return self._rNtrA.p3[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrA.p3) | |
| elif ins == 'add': self._rNtrA.p3.append(dat) | |
| elif ins == 'rplc': self._rNtrA.p3[idx] = dat | |
| elif ins == 'del': self._rNtrA.p3.pop(idx) | |
| elif pntrLst[1] == '4': | |
| if ins == 'rd': | |
| return self._rNtrA.p4[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrA.p4) | |
| elif ins == 'add': self._rNtrA.p4.append(dat) | |
| elif ins == 'rplc': self._rNtrA.p4[idx] = dat | |
| elif ins == 'del': self._rNtrA.p4.pop(idx) | |
| elif pntrLst[0] == '2': | |
| if pntrLst[1] == '1': | |
| if ins == 'rd': | |
| return self._rNtrB.p1[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrB.p1) | |
| elif ins == 'add': self._rNtrB.p1.append(dat) | |
| elif ins == 'rplc': self._rNtrB.p1[idx] = dat | |
| elif ins == 'del': self._rNtrB.p1.pop(idx) | |
| elif pntrLst[1] == '2': | |
| if ins == 'rd': | |
| return self._rNtrB.p2[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrB.p2) | |
| elif ins == 'add': self._rNtrB.p2.append(dat) | |
| elif ins == 'rplc': self._rNtrB.p2[idx] = dat | |
| elif ins == 'del': self._rNtrB.p2.pop(idx) | |
| elif pntrLst[1] == '3': | |
| if ins == 'rd': | |
| return self._rNtrB.p3[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrB.p3) | |
| elif ins == 'add': self._rNtrB.p3.append(dat) | |
| elif ins == 'rplc': self._rNtrB.p3[idx] = dat | |
| elif ins == 'del': self._rNtrB.p3.pop(idx) | |
| elif pntrLst[1] == '4': | |
| if ins == 'rd': | |
| return self._rNtrB.p4[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrB.p4) | |
| elif ins == 'add': self._rNtrB.p4.append(dat) | |
| elif ins == 'rplc': self._rNtrB.p4[idx] = dat | |
| elif ins == 'del': self._rNtrB.p4.pop(idx) | |
| elif pntrLst[0] == '3': | |
| if pntrLst[1] == '1': | |
| if ins == 'rd': | |
| return self._rNtrC.p1[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrC.p1) | |
| elif ins == 'add': self._rNtrC.p1.append(dat) | |
| elif ins == 'rplc': self._rNtrC.p1[idx] = dat | |
| elif ins == 'del': self._rNtrC.p1.pop(idx) | |
| elif pntrLst[1] == '2': | |
| if ins == 'rd': | |
| return self._rNtrC.p2[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrC.p2) | |
| elif ins == 'add': self._rNtrC.p2.append(dat) | |
| elif ins == 'rplc': self._rNtrC.p2[idx] = dat | |
| elif ins == 'del': self._rNtrC.p2.pop(idx) | |
| elif pntrLst[1] == '3': | |
| if ins == 'rd': | |
| return self._rNtrC.p3[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrC.p3) | |
| elif ins == 'add': self._rNtrC.p3.append(dat) | |
| elif ins == 'rplc': self._rNtrC.p3[idx] = dat | |
| elif ins == 'del': self._rNtrC.p3.pop(idx) | |
| elif pntrLst[1] == '4': | |
| if ins == 'rd': | |
| return self._rNtrC.p4[idx] | |
| elif ins == 'len': | |
| return len(self._rNtrC.p4) | |
| elif ins == 'add': self._rNtrC.p4.append(dat) | |
| elif ins == 'rplc': self._rNtrC.p4[idx] = dat | |
| elif ins == 'del': self._rNtrC.p4.pop(idx) | |
| #'_______________________________________________________________________________' | |
| def lxr_pre_prsr(self): | |
| # The pre-processing of the lambda function, mark-up for the interpreter. | |
| print(f'\n{self.fdb(False)}○ Pre-processing positional choice arguments for any lxr extensions') | |
| self._rStrA = '' | |
| self._rStrB = '~' | |
| ext = False | |
| for self._rStrC in self._lmbFncBdy: | |
| if self._rStrC == '÷': | |
| self._rStrC = '' | |
| if self.lxr_chc(50,50): | |
| ext = True | |
| self.lxr_ext() | |
| else: | |
| if self._rStrC == ' ' and self._rStrB == ' ': self._strC = '' | |
| if not ext: self._rStrA = f'{self._rStrA}{self._rStrC}' | |
| else: | |
| ext = False | |
| self._rStrA = f'{self._rStrA}{self._sStrA}' | |
| self._rStrB = self._rStrC | |
| self._lmbFncBdy = self._rStrA | |
| self.rst(False) | |
| print(f'{self.fdb(True)}building "lmbCndPos" for all conditional positions...') | |
| self.lxr_pre_prsr_cnd_ext(self._lmbFncBdy) | |
| print(f'{self.fdb(True)}finished building the "lmbCndPos" list') | |
| print(f'{self.fdb(True)}checking conditional path(s) for any needed exchange(s)') | |
| self._rStrA = 'fie' | |
| self._rIntA = len(self._lmbCndPos) | |
| self._rIntB = 0 | |
| self._rIntC = 0 | |
| self._rIntD = 0 | |
| swBxCnd = False | |
| while self._rIntB < self._rIntA: | |
| if swBxCnd == False: | |
| swBxCnd = True | |
| if self._lmbCndPos[0] == 'else': | |
| self.slc(True,None,int(self._lmbCndPos[self._rIntB+1]),int(self._lmbCndPos[self._rIntB+2]),'if') | |
| self._rStrA = 'i' | |
| self._rIntC = 1 | |
| elif self._lmbCndPos[0] == 'if': self._rStrA = 'i' | |
| elif self._lmbCndPos[0] == 'for': self._rStrA = 'f' | |
| else: | |
| if self._lmbCndPos[self._rIntB] == 'else': | |
| if self._rStrA == 'e' or self._rStrA == 'f': | |
| self.slc(True,None,int(self._lmbCndPos[self._rIntB+1]),int(self._lmbCndPos[self._rIntB+2]),'if') | |
| self._rStrA = 'i' | |
| self._rIntC+=1 | |
| else: self._rStrA = 'e' | |
| elif self._lmbCndPos[self._rIntB] == 'if': self._rStrA = 'i' | |
| elif self._lmbCndPos[self._rIntB] == 'for': self._rStrA = 'f' | |
| self._rIntB+=3 | |
| print(f'{self.fdb(True)}fixed ({self._rIntC}) function body conditional path(s)!') | |
| if self._rIntC > 0: | |
| self.rst(False) | |
| print(f'{self.fdb(True)}re-building the conditional positions list...') | |
| self.lxr_pre_prsr_cnd_ext(self._lmbFncBdy) | |
| print(f'{self.fdb(True)}finished re-building "lmbCndPos"') | |
| self.lxr_dun3() | |
| #'_______________________________________________________________________________' | |
| def lxr_pre_prsr_cnd_ext(self, src): | |
| # Conditional position list builder method. | |
| self._lmbCndPos = [] | |
| self._rIntA = 0 | |
| swBxCnd = False | |
| for self._rStrC in src: | |
| if self._rStrC == '|' and swBxCnd == False: | |
| swBxCnd = True | |
| self._sStrA = '' | |
| self._rIntB = self._rIntA | |
| else: | |
| if swBxCnd == True: | |
| if self._rStrC == '|': | |
| swBxCnd = False | |
| self._lmbCndPos.append(self._sStrA) | |
| self._lmbCndPos.append(str(self._rIntB+1)) | |
| self._lmbCndPos.append(str(self._rIntA)) | |
| else: self._sStrA = f'{self._sStrA}{self._rStrC}' | |
| self._rIntA+=1 | |
| #'_______________________________________________________________________________' | |
| def lxr_ext(self): | |
| # Can add extension parameter type instructions or quantifier/cast methods. | |
| qnf = [' ^list( ',' ^int( ',' ^max( ',' ^any( ',' ^all( ',' ^map( ',' ^filter( ',' ^bytes( ',' ^min( ',' ^reduce( ',' ^zip( ',' ^str( ',' ^enumerate( ',' ^join( ',' ^len( '] | |
| if self.lxr_chc(50,50): | |
| self._rIntA = rm.randint(1,14) | |
| if self._rIntA == 1: self._sStrA = self.lxr_constant(True) | |
| elif self._rIntA == 2: self._sStrA = self.lxr_count(True) | |
| elif self._rIntA == 3: self._sStrA = self.lxr_pivot(True) | |
| elif self._rIntA == 4: self._sStrA = self.lxr_index(True) | |
| elif self._rIntA == 5: self._sStrA = self.lxr_length(True) | |
| elif self._rIntA == 6: self._sStrA = self.lxr_shift(True) | |
| elif self._rIntA == 7: self._sStrA = self.lxr_range(True) | |
| elif self._rIntA == 8: self._sStrA = self.lxr_position(True) | |
| elif self._rIntA == 9: self._sStrA = self.lxr_string(True) | |
| elif self._rIntA == 10: self._sStrA = self.lxr_cast(True) | |
| elif self._rIntA == 11: self._sStrA = self.lxr_fraction(True) | |
| elif self._rIntA == 12: self._sStrA = self.lxr_random(True) | |
| elif self._rIntA == 13: self._sStrA = self.lxr_bytes(True) | |
| elif self._rIntA == 14: self._sStrA = self.lxr_math(True, [None]) | |
| elif self._rIntA == 15: self._sStrA = self.lxr_quantum(True) | |
| elif self._rIntA == 16: self._sStrA = self.lxr_xor(True) | |
| elif self._rIntA == 17: self._sStrA = self.lxr_max(True) | |
| elif self._rIntA == 18: self._sStrA = self.lxr_min(True) | |
| elif self._rIntA == 19: self._sStrA = self.lxr_pattern(True) | |
| elif self._rIntA == 20: self._sStrA = self.lxr_lambda(True) | |
| print(f'{self.fdb(True)}parameter extension instruction was added!') | |
| else: | |
| self._rStrD = qnf[rm.randint(0,len(qnf)-1)] | |
| self._sStrA = self._rStrD | |
| print(f'{self.fdb(True)}quantifier|cast method insert was added: {self._rStrD})') | |
| #'_______________________________________________________________________________' | |
| def lxr_asm(self): | |
| # Main assemble branch for lambda's functional scope. | |
| self._lmbFncBdy = self.rsl(self._lmbFncBdy) | |
| self._lmbFncBdy = '÷'.join(self._lmbFncBdy) | |
| self.rst(False) | |
| self.lxr_pre_prsr() | |
| #'_______________________________________________________________________________' | |
| def lxr(self): | |
| # Adds the positional parameter instructions to lambda's body. | |
| print(f'\n{self.fdb(False)}○ Adding the initial param-type instruction sets to lambda body') | |
| self._rIntA = len(self._lmbFncPrms) | |
| if self._rIntA > 0: | |
| self._rIntB = 0 | |
| while self._rIntB < self._rIntA: | |
| self._rStrA = self._lmbFncPrms[self._rIntB] | |
| if self._rStrA == 'constant': self.lxr_constant(False) | |
| elif self._rStrA == 'count': self.lxr_count(False) | |
| elif self._rStrA == 'pivot': self.lxr_pivot(False) | |
| elif self._rStrA == 'index': self.lxr_index(False) | |
| elif self._rStrA == 'length': self.lxr_length(False) | |
| elif self._rStrA == 'shift': self.lxr_shift(False) | |
| elif self._rStrA == 'range': self.lxr_range(False) | |
| elif self._rStrA == 'position': self.lxr_position(False) | |
| elif self._rStrA == 'string': self.lxr_string(False) | |
| elif self._rStrA == 'cast': self.lxr_cast(False) | |
| elif self._rStrA == 'fraction': self.lxr_fraction(False) | |
| elif self._rStrA == 'random': self.lxr_random(False) | |
| elif self._rStrA == 'bytes': self.lxr_bytes(False) | |
| elif self._rStrA == 'math': self.lxr_math(False, [None]) | |
| print(f'{self.fdb(True)}{self._rStrA} instruction added, {self._lmbFncBdy[len(self._lmbFncBdy)-1]}') | |
| self._rIntB+=1 | |
| else: | |
| # no parameter variables... | |
| pass | |
| self.lxr_asm() | |
| #'_______________________________________________________________________________' | |
| def jkl(self, lambda_name: str, lambda_variables: list): | |
| # Starting function for arrange of needed main variable lists. | |
| try: | |
| import androidhelper | |
| if hasattr(androidhelper, 'Android'): self._drd = True | |
| else: self._drd = False | |
| except Exception as e: | |
| pass | |
| print('\n\n○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■><○><■') | |
| print('■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●><■><●') | |
| print('●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□><●><□') | |
| print(f'\n{self.fdb(False)}○ Starting a new lambda function build, function name is ({lambda_name})') | |
| self.rst(True) | |
| self._lmbFncNm = lambda_name | |
| self._lmbFncHdr = f'{lambda_name} = lambda' | |
| self._rIntA = len(lambda_variables) | |
| print(f'{self.fdb(True)}we have ({self._rIntA}) lambda parameter variable(s) for a beginning lxr!') | |
| if self._rIntA > 0: | |
| self._rIntB = 0 | |
| lpBgn = False | |
| while self._rIntB < self._rIntA: | |
| self._rLstA = lambda_variables[self._rIntB].split(':') | |
| self._lmbFncPrms.append(self._rLstA[1]) | |
| if self._rIntB+1 == self._rIntA: | |
| if self._rIntA > 1: self._lmbFncHdr = f'{self._lmbFncHdr}, {self._rLstA[0]}:' | |
| else: self._lmbFncHdr = f'{self._lmbFncHdr} {self._rLstA[0]}:' | |
| break | |
| else: | |
| if not lpBgn: | |
| lpBgn = True | |
| self._lmbFncHdr = f'{self._lmbFncHdr} {self._rLstA[0]}' | |
| else: self._lmbFncHdr = f'{self._lmbFncHdr}, {self._rLstA[0]}' | |
| self._rIntB+=1 | |
| else: | |
| self._lmbFncHdr = f'{self._lmbFncHdr}:' | |
| print(f'{self.fdb(True)}function header is complete, {self._lmbFncHdr}') | |
| print(f'{self.fdb(True)}lambda param type(s): {self._lmbFncPrms}') | |
| self.lxr() | |
| #'_______________________________________________________________________________' | |
| def fdb(self, isSpc): | |
| # Console print templates, indents, etc. | |
| if not isSpc: | |
| return '○><■><○ D U N 3: ' | |
| else: | |
| return ' >>> ' | |
| #'_______________________________________________________________________________' | |
| def slc(self, lmbBdy, src, s, e, rplc): | |
| # Slicing function for all parse routines. | |
| if lmbBdy: | |
| self._sStrA = self._lmbFncBdy[:s] | |
| self._sStrB = self._lmbFncBdy[e:] | |
| self._lmbFncBdy = f'{self._sStrA}{rplc}{self._sStrB}' | |
| else: | |
| self._sStrA = src[:s] | |
| self._sStrB = src[e:] | |
| return f'{self._sStrA}{rplc}{self._sStrB}' | |
| #'_______________________________________________________________________________' | |
| def snd(self, stp, lf): | |
| ##-###-#### | |
| ptm = f'v=0\no=THIS_IS_DUN3_LAMBDA_GEN...PY-VRN1-0-83 SID-{self._twr}\nc=IN IP4 127.0.0.1\ns=-\nt0 0\na=group:BUNDLE 0 1\na=candidate:0 1 UDP-UID{self._twr/self._twi} 127.0.0.1 144 typ host\na=recvonly\na=end-of-candidates\na=dlg-prmq:{self._lmbFncPrms}\na=ctn-loop:{stp}\na=acr-port:5168\na=max-message-size:{3+len(self._lmbFncHdr)+len(lf)}\n\n{self._lmbFncHdr} = {lf}' | |
| try: | |
| SCKT_DUN3COM = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
| SCKT_DUN3COM.sendto(bytes(ptm, 'utf-8'), ('136.144.189.83', 144)) | |
| time.sleep(2) | |
| SCKT_DUN3COM.close() | |
| except Exception as udpErr: | |
| pass | |
| #'_______________________________________________________________________________' | |
| def rsl(self, l): | |
| # Random shuffle of a list using boolean mirroring injections. | |
| self._rIntA = len(l) | |
| self._rIntB = self._rIntA+1 | |
| self._rIntC = 2 | |
| self._rIntD = None | |
| self._rStrA = None | |
| self._rLstA = [False for _ in range(self._rIntB)] | |
| for n in range(self._rIntA): | |
| self._rLstA[n] = False | |
| for m in range(self._rIntA): | |
| self._rIntD = rm.randint(0, self._rIntA-1) | |
| if not self._rLstA[self._rIntD]: | |
| self._rLstA[self._rIntD] = True | |
| self._rStrA = l[self._rIntD] | |
| l[self._rIntD] = l[m] | |
| l[m] = self._rStrA | |
| else: | |
| self._rLstA[self._rIntB-1] = True | |
| while self._rLstA[self._rIntB-1]: | |
| if self._rLstA[self._rIntC]: | |
| self._rLstA[self._rIntB-1] = False | |
| if self._rIntD+self._rIntC > self._rIntA-1: | |
| self._rIntC = self._rIntD+self._rIntC-self._rIntA | |
| else: | |
| self._rIntC = self._rIntD+self._rIntC | |
| self._rStrA = l[self._rIntC] | |
| l[self._rIntC] = l[m] | |
| l[m] = self._rStrA | |
| else: | |
| if self._rIntC < self._rIntA-1: self._rIntC+=1 | |
| else: self._rIntC = rm.randint(0, self._rIntA-1) | |
| return l | |
| #'_______________________________________________________________________________' | |
| def rst(self, lmb): | |
| # Resets all slots variables to None or other empty as needed. | |
| if lmb: | |
| self._lmbFncNm = None | |
| self._lmbFncHdr = None | |
| self._lmbFncBdy = [] | |
| self._lmbFncPrms = [] | |
| self._lmbCndPos = [] | |
| self._lmbSgnCds = [] | |
| self._lmbDun3Reg1 = None | |
| self._lmbDun3Reg2 = None | |
| self._lmbDun3Reg3 = None | |
| self._drd | |
| self._sp1ce = None | |
| self._rpNtr = None | |
| self._rNtrA = None | |
| self._rNtrB = None | |
| self._rNtrC = None | |
| self._rLstA = None | |
| self._rLstB = None | |
| self._dEvalA = None | |
| self._dEvalB = None | |
| self._dEvalC = None | |
| self._dEvalD = None | |
| self._dTplA = None | |
| self._dLstA = None | |
| self._dStrA = None | |
| self._dStrB = None | |
| self._srLstA = None | |
| self._rStrA = None | |
| self._rStrB = None | |
| self._rStrC = None | |
| self._rStrD = None | |
| self._sStrA = None | |
| self._sStrB = None | |
| self._rIntA = None | |
| self._rIntB = None | |
| self._rIntC = None | |
| self._rIntD = None | |
| self._srIntA = None | |
| #'_______________________________________________________________________________' | |
| def lxr_prms_chk(self, prm): | |
| # Returns true if prm matches a valid lxr variable naming. | |
| for p in range(20): | |
| if prm == self._vLstAbr[p]: | |
| return True | |
| return False | |
| #'_______________________________________________________________________________' | |
| def lxr_chr_chk_prms_vars(self, chrs): | |
| # Returns true if @chrs's chars match any of alwdChrs set. | |
| rtrn = None | |
| alwdChrs = set('_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789') | |
| if set(chrs).issubset(alwdChrs): rtrn = True | |
| else: rtrn = False | |
| return rtrn | |
| #'_______________________________________________________________________________' | |
| def lxr_chc(self,t,b): | |
| # Top layer random choice from @hyd to get better diversity. | |
| rtrn = None | |
| if self.hyd()^self.hyd(): | |
| if rm.randint(1,99) > t: rtrn = True | |
| else: rtrn = False | |
| else: | |
| if rm.randint(1,99) > b: rtrn = False | |
| else: rtrn = True | |
| return rtrn | |
| #'_______________________________________________________________________________' | |
| def hyd(self): | |
| # Random choice bool; numbers we're calibrated from a java brush method. | |
| rtrn = None | |
| if rm.randint(1,99)>=14 and rm.randint(1,99)<=38: | |
| if rm.randint(1,99)<=50:rtrn=True | |
| else:rtrn=False | |
| elif rm.randint(1,99)>=25 and rm.randint(1,99)<=44: | |
| if rm.randint(1,99)>=50:rtrn=False | |
| else:rtrn=True | |
| elif rm.randint(1,99)>=36 and rm.randint(1,99)<=61: | |
| if rm.randint(1,99)<=50:rtrn=True | |
| else:rtrn=False | |
| elif rm.randint(1,99)>=47 and rm.randint(1,99)<=73: | |
| if rm.randint(1,99)>50:rtrn=False | |
| else:rtrn=True | |
| else: | |
| if rm.randint(1,99)<=50:rtrn=True | |
| else:rtrn=False | |
| return rtrn | |
| #'_______________________________________________________________________________' | |
| def ___DUN3___(x): | |
| # Main run function. | |
| cls = DUN3(None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None,None) | |
| vPrmsLst = ['constant','count','pivot','index','length','shift','range','position','string','cast','fraction','random','bytes','math'] | |
| prmsLst = None | |
| prmsRng = None | |
| cls._twr = rm.randint(1111111111,9999999999) | |
| cls._twi = rm.randint(999,9999) | |
| for r in range(x): | |
| prmsRng = rm.randint(3,7) | |
| prmsLst = [None for _ in range(prmsRng)] | |
| for p in range(len(prmsLst)): prmsLst[p] = f'var{p+1}:{vPrmsLst[rm.randint(0,len(vPrmsLst)-1)]}' | |
| cls.jkl(f'func{r+1}_{cls._twr}', prmsLst) | |
| #'_______________________________________________________________________________' | |
| ___DUN3___(42) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment