forked from drocta/TILDE-ATH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bif.py
51 lines (46 loc) · 1.53 KB
/
bif.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""
python drocta ~ATH interpreter
It interprets things written in drocta ~ATH
and is written in python.
Really, I thought the name was fairly self explanatory.
This file handles Bifurcation, reverse Bifurcation, and .DIE()
It creates the function for modifying values. (not the variables, the values)
"""
allValueObjs=[]
class value_obj:
def __init__(self,parts=()):
self.parts=parts
self.formsLeftOf=[]
self.formsRightOf=[]
self.whichHalve=(0,0)#left half is (1,0), right half is (0,1)
self.living=True
def bifurcate(self):
if(not self.parts):
leftHalf=value_obj()
leftHalf.formsLeftOf.append(self)
leftHalf.whichHalve=(1,0)
rightHalf=value_obj()
rightHalf.formsRightOf.append(self)
rightHalf.whichHalve=(0,1)
self.parts=(leftHalf,rightHalf)
return self.parts
def DIE(self):
self.living=False
def bifurcate(value):
if(not value.parts):
leftHalf=value_obj()
leftHalf.formsLeftOf.append(value)
leftHalf.whichHalve=(1,0)
rightHalf=value_obj()
rightHalf.formsRightOf.append(value)
rightHalf.whichHalve=(0,1)
value.parts=(leftHalf,rightHalf)
return value.parts
def unbifurcate(valueA,valueB):
for value in valueA.formsLeftOf:
if(value in valueB.formsRightOf):
return value
combined=value_obj((valueA,valueB))
valueA.formsLeftOf.append(combined)
valueB.formsRightOf.append(combined)
return combined