Jump to content

Search the Community

Showing results for tags 'balanced'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. This function will check for balanced parentheses in an expression just a simple exercise for fun (see Edit: today (july 5 2015) I discovered that the original listing that was here was lost for some reason (maybe one of the many issues arose after forum upgrades) I found a version of that function on my HD and I post again (hope it is the same version that was here before) ; https://gist.github.com/mycodeschool/7207410 ; Local $sExpr = "[{(1 + 3i)/((-1 - i)^2) + (-4 + i)(-4 - i)/(1 + i)}*{(1 + 3i)/((-1 - i)^2) + (-4 + i)(-4 - i)/(1 + i)}]" MsgBox(0, "Parenthesis check", AreParanthesesBalanced($sExpr)) Exit ; -------------------------------------------------------- ; Returns True if parenthesis in $sExpression are balanced ; -------------------------------------------------------- Func AreParanthesesBalanced($sExpression) Local $sStack = "" For $i = 1 To StringLen($sExpression) If StringInStr('({[', StringMid($sExpression, $i, 1)) Then ; opening parenthesis $sStack &= StringMid($sExpression, $i, 1) ElseIf StringInStr(')}]', StringMid($sExpression, $i, 1)) Then ; a closing parenthesis If Not StringLen($sStack) Or Not _ArePair(StringRight($sStack, 1), StringMid($sExpression, $i, 1)) Then Return False Else $sStack = StringLeft($sStack, StringLen($sStack) - 1) EndIf EndIf Next Return Not StringLen($sStack) ? True : False #cs ; alternative for old AutoIt versions ; without ternary operator If Not StringLen($sStack) Then Return True Else Return False EndIf #ce EndFunc ;==>AreParanthesesBalanced Func _ArePair($sOpening, $sClosing) If ($sOpening = '(' And $sClosing = ')') Then Return True If ($sOpening = '{' And $sClosing = '}') Then Return True If ($sOpening = '[' And $sClosing = ']') Then Return True Return False EndFunc ;==>ArePair
×
×
  • Create New...