FANDOM


Sequence Generator Code Version 2

I am developing general purpose code to generate long strings of finite integers according to rules that can be written using the correct syntax.

Version 2 of this code is being finalised and replaces my previous work on Version 1


Changes in Version 2

Version 2 has been modified to enable fairly straight forward coding rules to translate (render) Sequences into strings of words or mathematical expressions.

Another smaller change was a rationalisation of the various symbols that can be used to keep the code as simple as possible.

Refer to my updates in the 'Syntax section' of my main blog for more information.


Example of Changes in Version 2

Here is a simple example of sequence generator code that will generate any integer up to \(10^{10}\). This example will illustrate how Sequence Generator Code works.

s_x = (e_0,[Simple(RealNumber) = [e_0]])

e_x = (C_d<2,C_d>(0:(i_x,[[i_x]]),(i_E,i_M,e_a<C_d..i_E,[10^[i_E]*[i_M]+[e_a]])))

i_x = (C_x<10-U_x,[[C_x]+[U_x]])

This simple example can be used to generate integers up to \(10^{10}\) using basic Exponentiation (^), Multiplication (\(*\)) and Addition (\(+\)). This is not intended to be interesting in itself, but helps to illustrate what Sequence Generator Code does and how it can be used.

Example of Rendering Sequences into JSON format

By slightly modifying the Sequence Generator Code we can make the code render JSON format string output instead. A good JSON Viewer can be found here.

s_x = ("e_0,[{""V_r"":RealNumber,""e_0"":[e_0]}])

e_x = (C_d<2,C_d>(0:(i_x,[[i_x]]),(i_E,i_M,e_a<C_d..i_E,[{""i_E"":[i_E],""i_M"":[i_M],""e_a"":[e_a]}])))

i_x = (C_x<10-U_x,[[C_x]+[U_x]])

A comparison of the two code sets with some input values is:

Input Math Output JSON Output
1 Simple(1)=0 {"V_r":1,"e_0":0}
9.5 Simple(9.5)=6000000007 {"V_r":9.5,"e_0":{"i_E":9,"i_M":6,"e_a":7}}
9.995 Simple(9.995)=9410000089 {"V_r":9.995,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":4,"e_a":{"i_E":7,"i_M":1,"e_a":{"i_E":1,"i_M":8,"e_a":9}}}}}


Sequence Generator Code: Interpreter

Sequence Generator Code needs to be be interpreted using a program in a conventional programming language. I am using VBA in Microsoft Excel to do this. I plan to write a Javascript version in due course and make it available online on a web page.

The VBA code for Microsoft Excel is show below. It consists of 2 Class Modules: Node and Sequence, and a code Module: Interpreter

Class Modules are used in VBA for Microsoft Excel to define Object Classes.

Class Module: Node

Option Explicit
Public TreeParent As Node
Public Tree As Collection

Public nRender As String, nApprox As String, Name As String, Start As Integer

Public Sub Initiate(iParent As Node, iName As String, iStart As Integer)
Set TreeParent = IIf(iParent Is Nothing, Me, iParent)
Set Tree = New Collection

nRender = ""
nApprox = ""
Name = iName
Start = iStart
End Sub

Public Sub Delete()
Dim n As Node

For Each n In Tree
    If Name <> n.Name Then n.Delete
    Next n

Set Tree = Nothing
Set TreeParent = Nothing
End Sub

Public Function Range(rFinish As Integer) As String
Range = BuildRange(Start, IIf(rFinish = 0, Finish, rFinish))
End Function

Public Function Finish() As Integer
If Tree.Count = 0 Then Finish = Start - IIf(Left(Name, 1) = "V", 1, 0) Else Finish = Tree(Tree.Count).Finish
End Function

Public Function FindParent(fpName As String) As Node
Set FindParent = Me
While FindParent.Name <> fpName
    If UpParent(FindParent) Is Nothing Then Exit Function
    Wend
End Function

Public Function FindAncestor(faName As String) As Node
Dim n As Node

Set FindAncestor = Nothing
Set n = Me
While FindAncestor Is Nothing
    On Error Resume Next
    Set FindAncestor = n.Tree(faName)
    On Error GoTo 0
    
    If FindAncestor Is Nothing Then If UpParent(n) Is Nothing Then Exit Function
    Wend
End Function

Private Function UpParent(upNode As Node) As Node
If (upNode Is upNode.TreeParent) Then Set upNode = Nothing Else Set upNode = upNode.TreeParent
Set UpParent = upNode
End Function

Public Function EncodeSubscript(esCode As String) As String
If Len(esCode) <= 3 Then EncodeSubscript = esCode Else EncodeSubscript = Left(esCode, 2) & Syntax(Mid(esCode, 3), "")
End Function

Public Function Syntax(sVariable As String, sType As String) As String
Dim s As String, i As Integer

Syntax = sVariable
If Syntax = "" Then Exit Function Else If Number(Syntax) Then Exit Function

s = sVariable
Syntax = Parse(s, ",")
If s <> "" Then
    Syntax = Syntax(Syntax, sType) & "," & Syntax(s, sType)
    Exit Function
    End If
    
s = Syntax
Syntax = Parse(s, "..")
If s <> "" Then
    Syntax = BuildRange(Syntax(Syntax, "S"), Syntax(s, "F"))
    Exit Function
    End If

s = Syntax
Syntax = Expression(s, sType)

i = Len(Syntax)
If i < 6 Then
    s = Left(Syntax, 1)
    If i = 5 And s = "M" Then
        s = FindAncestor(Mid(Syntax, 3)).Approx
        If s <> "-1" Then Syntax = IIf(s = "0", "0", "1"):  Exit Function
        End If
    If i = 3 Then
        If s = "U" Then Syntax = Upper(Mid(Syntax, 3)):  Exit Function
        s = Variable(Syntax, sType)
        If s <> "" Then Syntax = s: Exit Function
        End If
    
    If sType = "" Then s = ActiveSequence.CodeReplace(Syntax) Else s = Syntax(Syntax, sType)
    If s <> "" Then Syntax = s
    End If
End Function

Public Function Expression(eExpression As String, eType As String) As String
Expression = Calculate(eExpression, "-", eType)
Expression = Calculate(Expression, "+", eType)
Expression = Calculate(Expression, "*", eType)
Expression = Calculate(Expression, "^", eType)
End Function

Private Function Calculate(cExpression As String, cSign As String, cType As String) As String
Calculate = Parse(cExpression, cSign)
If cExpression <> "" Then Calculate = Math(Syntax(Trim(Calculate), cType), cSign, Syntax(Trim(cExpression), cType))
End Function

Public Function Minimum() As Boolean
Minimum = (Approx = 0)
End Function

Public Function Approx() As String
Dim i As Integer, j As Integer, k As Integer

If nApprox <> "" Then Approx = nApprox:   Exit Function

Select Case Left(Name, 1)
Case "V", "C"
    Approx = nRender
Case Else
    Approx = "0"
    j = Finish
    For i = Start To j
        k = ActiveSequence.sArray(i)
        If k > 0 Then
            If i = j Then Approx = CStr(k) Else Approx = "10"
            Exit For
            End If
        Next i
    End Select
    
nApprox = Approx
End Function

Public Function Variable(vName As String, vType As String) As String
Variable = ""
With FindAncestor(vName)
    On Error Resume Next
    If Left(.Name, 1) = "V" Or vType = "" Then Variable = .nRender Else If vType = "A" Then Variable = .Approx Else If vType = "R" Then Variable = .Range(0) Else If vType = "S" Then Variable = CStr(.Start) Else Variable = CStr(.Finish)
    On Error GoTo 0
    End With
End Function


Class Module: Sequence

Option Explicit
Public sArray As Collection
Private Library As Collection
Private ActiveNode As Node
Private sMax As Integer
Private sReal As Double
Private sMode As Boolean, sStart As Integer, sFinish As Integer, sProgram As String

Public Function Initiate(iLibrary As Collection, gReal As Double, gSize As Integer, gCode As String, gParent As Node, gEvaluate As String) As Node
Set sArray = New Collection
Set Library = iLibrary
Set ActiveSequence = Nothing
sMax = gSize
sReal = gReal
sMode = False

Set Initiate = New Node
Initiate.Initiate gParent, gCode, 1

If gEvaluate <> "" Then Evaluate gParent.Syntax(gEvaluate, "R")
Code Initiate, CodeReplace(gCode)
End Function

Public Sub Delete()
Set ActiveSequence = Nothing
Set Library = Nothing
Set sArray = Nothing
End Sub

Public Function Rendered() As String
Dim i As Integer

Rendered = ""
For i = 1 To sArray.Count
    Rendered = IIf(i = 1, "", Rendered & ",") & sArray(i)
    Next i
End Function

Public Function CodeReplace(crCode As String) As String
Dim i As Integer, s As String

i = Len(crCode)
If i = 1 Then s = crCode Else s = Left(crCode, i - 2)

CodeReplace = ""
On Error Resume Next
CodeReplace = Library(s)
On Error Resume Next

s = Right(crCode, 1)
i = Upper(s)
CodeReplace = Replace(CodeReplace, "[U_x]", CStr(i))
CodeReplace = Replace(CodeReplace, "U_x", CStr(i))
CodeReplace = Replace(CodeReplace, "x", s)
End Function

Private Function Place() As Integer
Dim i As Integer

Place = 0
If sMode Then
    If sFinish = -1 Then i = sStart Else i = sArray(sStart)
    sStart = sStart + 1
    
    If sStart > sFinish Then
        If sProgram = "" Then
            i = i - 1
            sMode = False
        Else
            Execute sProgram
            End If
        End If
    If i > 0 Then Place = GetValue(i)
    If Place < i Then sMode = False
    End If

sArray.Add Place
End Function

Private Function GetValue(gvM As Integer) As Integer
If sArray.Count > sMax Then
    GetValue = 0
Else
    If sReal = -1 Then
        GetValue = gvM
    Else
        sReal = sReal * (gvM + 1)
        GetValue = Int(sReal)
        sReal = sReal - GetValue
        End If
    End If
End Function

Public Sub Evaluate(eProgram As String)
If eProgram <> "" Then If Not sMode Then sProgram = Compile(eProgram): If sProgram <> "" Then Execute sProgram
End Sub

Private Sub Execute(eProgram As String)
Dim s As String, t As String

Set ActiveSequence = Me

t = Parse(eProgram, ",")
s = Parse(t, "<")
If t = "" Then
    sStart = CInt(Parse(s, ".."))
    If s = "" Then sFinish = -1 Else sFinish = CInt(s)
Else
    With New Sequence
        .Initiate Library, -1, sMax - sArray.Count, CodeReplace(s), ActiveNode, Mid(t, 2, Len(t) - 2)
        s = .Rendered
        .Delete
        End With
         
    sMode = False
    Evaluate s & IIf(sProgram = "", "", "," & sProgram)
    End If
sMode = True
End Sub

Private Function Compile(eProgram As String) As String
Dim s As String, t As String, i As Integer, j As Integer

s = eProgram
t = Parse(s, ",")
Compile = ActiveNode.Syntax(t, "R")

If s <> "" Then
    s = Compile(s)
    If s = "" Then
        If Compile <> t Then Compile = Compile(Compile):  Exit Function
    Else
        Compile = Compile & "," & s:  Exit Function
        End If
Else
    If Compile <> t Then Compile = Compile(Compile):  Exit Function
    
    s = Compile
    Compile = Parse(s, ">")
    If s <> "" Then Compile = Choice(ActiveNode.Syntax(Compile, ""), s)
    
    s = Compile
    Compile = Parse(s, "..")
    If s = "" Then
        If Compile = "0" Then Compile = ""
    Else
        i = CInt(Compile)
        j = CInt(s)
        While sArray(j) = 0 And j >= i
            j = j - 1
            Wend
        If j < i Then Compile = "" Else Compile = BuildRange(i, j)
        End If
    End If
End Function

Private Sub Code(cParent As Node, cCode As String)
Dim s As String, t As String, b As Boolean

If cCode = "" Then Exit Sub

'If Debugger Then Debug.Print "CODE cParent=" & cParent.Name & " cCode=" & cCode

Set ActiveNode = cParent

t = Parse(cCode, ",")
s = Parse(t, "=")
If t <> "" Then
    With TreeAdd(cParent, s)
        .nRender = cParent.Syntax(t, "A")
        
        'If Debugger Then Debug.Print "CODE cParent=" & cParent.Name & " cCode=" & s & "=" & .nRender
        End With
Else
    t = s
    s = Parse(t, ">")
    If t <> "" Then
        Code cParent, Choice(cParent.Syntax(s, "A"), t)
    Else
        t = ParseTrim(s, "[", "]")
        If t <> s Then Render cParent, t Else Encode cParent, t
        End If
    End If

If cCode <> "" Then Code cParent, cCode
End Sub

Private Function Render(rNode As Node, rCode As String) As String
Dim s As String, t As String

Render = ""
If rCode = "" Then Exit Function

'If Debugger Then Debug.Print "RENDER rNode=" & rNode.Name & " rCode=" & rCode

Do: s = ParseExtract(t, rCode, "[", "]")
    If Len(s) > 1 Then
        Select Case Left(s, 1)
        Case "^", "*", "+", "-"
            Render = Math(Render, Left(s, 1), Mid(s, 2))
        Case Else
            Render = Render & s
            End Select
    Else
        Render = Render & s
        End If
    
    Select Case Len(t)
    Case 0
    Case 2
        Select Case Right(Render, 1)
        Case "^", "*", "+", "-"
            Render = Math(Left(Render, Len(Render) - 1), Right(Render, 1), rNode.nRender)
        Case Else
            Render = Render & rNode.nRender
            End Select
    Case Else
        Select Case Right(Render, 1)
        Case "^", "*", "+", "-"
            Render = Math(Left(Render, Len(Render) - 1), Right(Render, 1), rNode.Variable(ParseTrim(t, "[", "]"), ""))
        Case Else
            t = rNode.EncodeSubscript(ParseTrim(t, "[", "]"))
            Render = Render & rNode.Variable(t, "")
            End Select
        End Select
    Loop Until t = ""

rNode.nRender = Render
'If Debugger Then Debug.Print "RENDER rNode=" & rNode.Name & "=" & rNode.nRender
End Function

Private Function Encode(eNode As Node, eCode As String) As Node
Dim s As String, t As String

Set Encode = eNode
If eCode = "" Then Exit Function

t = " eCode=" & eCode
'If Debugger Then Debug.Print "ENCODE eNode=" & eNode.Name & t

s = Parse(eCode, "<")
If eCode <> "" Then Evaluate eNode.Syntax(eCode, "R")

Select Case Left(s, 1)
Case "C"
    Set Encode = TreeAdd(eNode, s)
    Encode.nRender = Place()

    If Debugger Then Debug.Print "ENCODE eNode=" & eNode.Name & t & "=" & Encode.nRender & " r=" & sReal
Case Else
    s = eNode.EncodeSubscript(s)
    Set Encode = TreeAdd(eNode, s)
    Code Encode, CodeReplace(s)
    End Select
End Function

Private Function TreeAdd(taNode As Node, taName As String) As Node
Set TreeAdd = New Node
TreeAdd.Initiate taNode, taName, sArray.Count + 1
taNode.Tree.Add TreeAdd, taName
End Function


Module: Interpreter

Option Explicit
Public ActiveSequence As Sequence
Public Debugger As Boolean

Public Function Alpha(r As Double, aRuler As String, s As String) As String
Dim d As Double, e As Double, t As String

Debugger = True
If Debugger Then Debug.Print "ALPHA r=" & r

e = 1000 ^ 0.5

Select Case aRuler
Case ""
    If r <= 1 Then
        d = r * 0.25 + 0
    ElseIf r <= 2 Then
        d = (r - 1) * 0.5 + 0.25
    ElseIf r <= 3 Then
        d = (r - 2) * 0.00390625 + 0.75
    ElseIf r <= 4 Then
        d = (r - 3) * 0.01171875 + 0.75390625
    ElseIf r <= 10 Then
        d = (r - 4) / 6 * 0.050875 + 0.765625
    ElseIf r <= e Then
        d = (r - 10) / (e - 10) * 0.059 + 0.8165
    ElseIf r <= 100 Then
        d = (r - e) / (100 - e) * 0.030875 + 0.8755
    ElseIf r < 10000 Then
        d = (r - 100) / (10000 - 100) * 0.093625 + 0.906375
    Else
        d = 0
        End If
Case "0"
    'If r <= 3 Then
    '    d = r / 3 * 0.75
    'ElseIf r <= 4 Then
    '    d = (r - 3) * 0.00390625 + 0.75
    If r <= 1 Then
        d = r * 0.25 + 0
    ElseIf r <= 2 Then
        d = (r - 1) * 0.5 + 0.25
    ElseIf r <= 4 Then
        d = (r - 2) / (4 - 2) * 0.00390625 + 0.75
    ElseIf r <= 10 Then
        d = (r - 4) / (10 - 4) * 0.01171875 + 0.75390625
    ElseIf r <= e Then
        d = (r - 10) / (e - 10) * 0.050875 + 0.765625
    ElseIf r <= 100 Then
        d = (r - e) / (100 - e) * 0.059 + 0.8165
    Else
        d = 0
        End If
Case "1"
    'If r <= 4 Then
    '    d = r / 4 * 0.75
    'ElseIf r <= 10 Then
    '    d = (r - 4) / (10 - 4) * 0.00390625 + 0.75
    If r <= 1 Then
        d = r * 0.25 + 0
    ElseIf r <= 2 Then
        d = (r - 1) * 0.5 + 0.25
    ElseIf r <= e Then
        d = (r - 2) / (e - 2) * (0.01171875 + 0.00390625) + 0.75
    ElseIf r <= 100 Then
        d = (r - e) / (100 - e) * 0.050875 + 0.765625
    Else
        d = 0
        End If
    End Select
    
Alpha = RunSequence(r, s, d, 300)

t = Alpha
t = Replace(t, "S(2,1,1)", "4")
t = Replace(t, "S(4,0,1)", "5")
t = Replace(t, "S(2,T(0),1)", "8")
t = Replace(t, "S(8,1,1)", "16")
t = Replace(t, "S(8,1,2)", "32")
t = Replace(t, "S(2,T(0) + 1,1)", "2048")
If t <> Alpha Then Alpha = Alpha & " = " & t
End Function

Public Function eS(r As Double, s As String) As String
Dim d As Double

Debugger = False
If Debugger Then Debug.Print "S FUNCTION r=" & r

If r < 1 Then d = r / 2 Else d = Log(r) / Log(4) / 8 * 0.5 + 0.5

eS = RunSequence(r, s, d, 100)
End Function

Public Function BetaDepth(r As Double, v As Integer, bdDepth As Integer) As String
Dim d As Double

If r < 1 Then d = r / 2 Else d = Log(r) / Log(v) / 2 / (v + 1) + 0.5

BetaDepth = RunSequence(r, "b", d, bdDepth)
End Function

Public Function Simple(r As Double, s As String) As String
Debugger = False
If Debugger Then Debug.Print "SIMPLE r=" & r

Simple = RunSequence(r, s, Log(r) / Log(10), 100)
End Function

Private Function RunSequence(rsR As Double, rsCode As String, rsReal As Double, rsDepth As Integer) As String
Dim s As New Sequence, n As Node, c As New Collection

c.Add "C_x<V_v-U_x,[[C_x]+[U_x]]", "i"

c.Add "V_v=10,e_0,[Simple(" & rsR & ") = [e_0]]", "p"
c.Add "C_d<2,C_d>(0:(i_x,[[i_x]]),(i_E,i_M,e_a<C_d..i_E,[10^[i_E]*[i_M]+[e_a]]))", "e"

c.Add "V_v=10,f_0,[{""V_r"":" & rsR & ",""f_0"":[f_0]}]", "q"
c.Add "C_d<2,C_d>(0:(i_x,[[i_x]]),(i_E,i_M,f_a<C_d..i_E,[{""i_E"":[i_E],""i_M"":[i_M],""f_a"":[f_a]}]))", "f"

c.Add "V_v=2,n_x,[[n_x]]", "a"
c.Add "C_d<2,C_d>(0:(i_x,[[i_x]]),(V_n=1,s_0,[[s_0]]))", "n"
'c.Add "x>(0:[[V_v]],[[s_x-1]]),t_x,t_x>(0:(n_c<V_n,n_c>(0:,[[]+[n_c]])),(n_C<V_n,V_n=C_d..n_C,[S([],[t_x],[n_C])],s_x+1<t_x,[[s_x+1]]))", "s"
c.Add "x>(0:[[V_v]],[[s_x-1]]),w_x,w_x>(0:(n_c<V_n,n_c>(0:,[[]+[n_c]])),(n_C<V_n,V_n=C_d..n_C,[S([],[w_x],[n_C])],s_x+1<w_x,[[s_x+1]]))", "s"
c.Add "V_n=1,t_x,[[t_x]]", "w"
c.Add "C_t<2,C_t>(0:(n_x<V_n,[[n_x]]),(t_a,V_t=C_t..t_a,u_0,[[u_0]]))", "t"
'c.Add "C_t<2,C_t>(0:(i_x<V_n,[[i_x]]),(t_a,V_t=C_t..t_a,u_0,[[u_0]]))", "t"
c.Add "x>(0:[T([t_a])],[[u_x-1]]),t_b<V_t,t_b>(0:(t_c<V_t,t_c>(0:,[[]+[t_c]])),(t_C<V_t,V_t=C_t..t_C,[S([],[t_b],[t_C])],u_x+1<t_b,[[u_x+1]]))", "u"
'c.Add "x>(0:[T([t_a])],[[u_x-1]]),w_b<V_t,w_b>(0:(t_c<V_t,t_c>(0:,[[]+[t_c]])),(t_C<V_t,V_t=C_t..t_C,[S([],[w_b],[t_C])],u_x+1<w_b,[[u_x+1]]))", "u"
'c.Add "V_n=1,t_x,[[w_x]]", "w"
'c.Add "x>(0:[T([t_a])],[[u_x-1]]),t_b<V_t,x>(0:,V_t=C_t..t_C),t_b>(0:(t_c<V_t,t_c>(0:,[[]+[t_c]])),(t_C<V_t,[S([],[t_b],[t_C])],u_x+1<t_b,[[u_x+1]]))", "u"

Set n = s.Initiate(c, rsReal, rsDepth, rsCode, Nothing, "")

RunSequence = n.nRender

Set c = Nothing

n.Delete
Set n = Nothing
s.Delete
Set s = Nothing
End Function

'STRING INTERPRETER FUNCTIONS
Public Function BuildRange(brStart As Integer, brFinish As Integer) As String
If brStart = brFinish Then BuildRange = ActiveSequence.sArray(brStart) Else BuildRange = brStart & ".." & brFinish
End Function

Public Function Choice(cValue As String, cCode As String) As String
Dim s As String, t As String, u As String, v As String

'If Debugger Then Debug.Print "CHOICE cValue=" & cValue & " cCode=" & cCode

Choice = ""
u = cCode
While u <> ""
    t = Parse(u, ",")
    v = t
    s = Parse(t, ":")
    If s = v Then
        Choice = s & IIf(u = "", "", "," & u)
        Exit Function
    Else
        If s = cValue Then Choice = t: Exit Function
        End If
    Wend
End Function

Public Function Parse(pCode As String, pChar As String) As String
Dim s As String, t As String, i As Integer, j As Integer, b As Boolean

Parse = pCode
If pCode = "" Then Exit Function

If InStr(Parse, pChar) = 0 Then
    pCode = ""
    Exit Function
    End If

'If Debugger Then Debug.Print "PARSE pCode=" & pCode & " pChar=" & pChar

b = (pChar = "[" Or pChar = "]")

j = Len(Parse)
For i = 1 To j
    s = Mid(pCode, i, Len(pChar))
    Select Case s
    Case pChar, "(", "["
        If Not (s = "(" And b) Then
            Parse = Left(pCode, i - 1)
            pCode = Mid(pCode, i + Len(pChar))
            Exit For
            End If
        End Select
    Next i
If i > j Then pCode = "":  Exit Function

If s <> pChar Then
    If s = "(" Then t = ")" Else t = "]"
    s = s & Parse(pCode, t) & t
    
    If pCode <> "" Then
        Parse = Parse & s & Parse(pCode, pChar)
    Else
        t = ParseTrim(s, "(", ")")
        If b Or Parse <> "" Or t = s Then
            Parse = Parse & t
        Else
            pCode = t
            Parse = Parse(pCode, pChar)
            End If
        End If
    End If
End Function

Public Function ParseExtract(peContents As String, peCode As String, peOpen As String, peClose As String) As String
ParseExtract = peCode
peContents = ""
If ParseExtract = "" Then Exit Function

'If Debugger Then Debug.Print "PARSEEXTRACT peContents=" & peContents & " peCode=" & peCode & " peOpen=" & peOpen & " peClose=" & peClose

ParseExtract = Parse(peCode, peOpen)
If peCode <> "" Then peContents = peOpen & Parse(peCode, peClose) & peClose
End Function

Public Function ParseTrim(ptCode As String, ptOpen As String, ptClose As String) As String
ParseTrim = ptCode
If Left(ptCode, 1) = ptOpen Then If Right(ptCode, 1) = ptClose Then ParseTrim = Mid(ptCode, 2, Len(ptCode) - 2)
End Function

'PSEUDO MATH FUNCTIONS
Public Function Number(nInput As String) As Boolean
Number = False
On Error Resume Next
Number = (nInput = CStr(CDbl(nInput)))
On Error GoTo 0
End Function

Public Function Upper(uChar As String) As Integer
Upper = Asc(uChar)
If Upper >= Asc("A") And Upper <= Asc("Z") Then Upper = 1 Else Upper = 0
End Function

Public Function Math(mS As String, mSign As String, mT As String) As String
Math = IIf(mS = "", "0", mS)
Select Case mSign
Case "+", "-"
    If mT = "0" Then Exit Function Else Math = Math & " " & mSign & " " & mT
    On Error Resume Next
    Math = CStr(CDbl(mS) + CDbl(mT) * IIf(mSign = "+", 1, -1))
    On Error GoTo 0
Case "*"
    If mT = "1" Then Exit Function Else Math = Math & "." & IIf(Len(mT) > 3, "(" & mT & ")", mT)
    On Error Resume Next
    Math = CStr(CDbl(mS) * CDbl(mT))
    On Error GoTo 0
Case "^"
    If mT = "1" Then Exit Function Else Math = Math & "^" & IIf(Len(mT) > 1, "{" & mT & "}", mT)
    On Error Resume Next
    Math = CStr(CDbl(mS) ^ CDbl(mT))
    On Error GoTo 0
Case "^^"
    If mT = "1" Then Exit Function Else Math = "(" & Math & "\uparrow\uparrow " & mT & ")"
    End Select
End Function


Test Bed

Various results will be presented here while Version 2 is being stabilised:

Simple(1) = 0

Simple(1.2) = 1

Simple(1.4) = 2

Simple(1.5) = 3

Simple(1.6) = 4

Simple(1.8) = 5

Simple(2) = 6

Simple(2.3) = 7

Simple(2.6) = 8

Simple(2.9) = 9

Simple(3.165) = 10

Simple(3.17) = 11

Simple(3.175) = 12

Simple(3.18) = 13

Simple(3.2) = 18

Simple(3.3) = 39

Simple(3.4) = 60

Simple(3.5) = 81

Simple(4) = 816

Simple(5) = 60004

Simple(6) = 1000001

Simple(7) = 20807002

Simple(8) = 300000006

Simple(9) = 2000000422

Simple(9.5) = 6000000007

Simple(9.9) = 9000000005

Simple(9.95) = 9000004004

Simple(9.99) = 9080400005

Simple(9.995) = 9410000089

Simple(9.999) = 9880000006

Simple(9.9995) = 9900000009

Simple(9.9999) = 9906000004

Simple(9.99995) = 9930000440

Simple(9.99999) = 9980007002

{"V_r":1,"e_0":0}

{"V_r":1.2,"e_0":1}

{"V_r":1.4,"e_0":2}

{"V_r":1.5,"e_0":3}

{"V_r":1.6,"e_0":4}

{"V_r":1.8,"e_0":5}

{"V_r":2,"e_0":6}

{"V_r":2.3,"e_0":7}

{"V_r":2.6,"e_0":8}

{"V_r":2.9,"e_0":9}

{"V_r":3.165,"e_0":{"i_E":1,"i_M":1,"e_a":0}}

{"V_r":3.17,"e_0":{"i_E":1,"i_M":1,"e_a":1}}

{"V_r":3.175,"e_0":{"i_E":1,"i_M":1,"e_a":2}}

{"V_r":3.18,"e_0":{"i_E":1,"i_M":1,"e_a":3}}

{"V_r":3.2,"e_0":{"i_E":1,"i_M":1,"e_a":8}}

{"V_r":3.3,"e_0":{"i_E":1,"i_M":3,"e_a":9}}

{"V_r":3.4,"e_0":{"i_E":1,"i_M":6,"e_a":0}}

{"V_r":3.5,"e_0":{"i_E":1,"i_M":8,"e_a":1}}

{"V_r":4,"e_0":{"i_E":2,"i_M":8,"e_a":{"i_E":1,"i_M":1,"e_a":6}}}

{"V_r":5,"e_0":{"i_E":4,"i_M":6,"e_a":4}}

{"V_r":6,"e_0":{"i_E":6,"i_M":1,"e_a":1}}

{"V_r":7,"e_0":{"i_E":7,"i_M":2,"e_a":{"i_E":5,"i_M":8,"e_a":{"i_E":3,"i_M":7,"e_a":2}}}}

{"V_r":8,"e_0":{"i_E":8,"i_M":3,"e_a":6}}

{"V_r":9,"e_0":{"i_E":9,"i_M":2,"e_a":{"i_E":2,"i_M":4,"e_a":{"i_E":1,"i_M":2,"e_a":2}}}}

{"V_r":9.5,"e_0":{"i_E":9,"i_M":6,"e_a":7}}

{"V_r":9.9,"e_0":{"i_E":9,"i_M":9,"e_a":5}}

{"V_r":9.95,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":3,"i_M":4,"e_a":4}}}

{"V_r":9.99,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":7,"i_M":8,"e_a":{"i_E":5,"i_M":4,"e_a":5}}}}

{"V_r":9.995,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":4,"e_a":{"i_E":7,"i_M":1,"e_a":{"i_E":1,"i_M":8,"e_a":9}}}}}

{"V_r":9.999,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":8,"e_a":{"i_E":7,"i_M":8,"e_a":6}}}}

{"V_r":9.9995,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":9,"e_a":9}}}

{"V_r":9.9999,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":9,"e_a":{"i_E":6,"i_M":6,"e_a":4}}}}

{"V_r":9.99995,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":9,"e_a":{"i_E":7,"i_M":3,"e_a":{"i_E":2,"i_M":4,"e_a":{"i_E":1,"i_M":4,"e_a":0}}}}}}

{"V_r":9.99999,"e_0":{"i_E":9,"i_M":9,"e_a":{"i_E":8,"i_M":9,"e_a":{"i_E":7,"i_M":8,"e_a":{"i_E":3,"i_M":7,"e_a":2}}}}}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.