Questions tagged [parentheses]

The symbols "(" and ")", commonly used in programming languages. Please use this tag only if the specific usage of these symbols is a relevant part of the question.

The parentheses "(" and ")" are special cases of brackets, along with square brackets ("[" and "]") and curly brackets (or braces) ("{", "}").

Parentheses (singular parenthesis) have many uses in most programming languages, such as:

  • indicate the arguments of a function call;
  • specify the order of evaluation/execution of expressions;
  • create lists/arrays/vectors.
1024 questions
-3
votes
1 answer

Why "operand = (operand*10) + (expression[i] - '0');"

Why is the following code doing operand * 10? Why doesn't it just do operand = (expression[i] - '0'); rather than operand = (operand*10) + (expression[i] - '0'); else if(IsNumericDigit(expression[i])) { int operand = 0; …
-3
votes
1 answer

Type Mismatch in Scala Code

Here is the function for balancing parenthesis in scala. I am getting Error:(36, 10) type mismatch; found : Unit required: Int a=a+1 var a = 0 def balance(chars: List[Char]): Boolean = { if(chars.isEmpty) …
user459
  • 111
  • 8
-3
votes
1 answer

Remove date between parentheses in PHP

I would remove the date in parentheses, including the brackets it ourselves, PHP, using a regular expression. Example : Artist - title (2016) And I want this : Artiste - title I have tried many things, but never managed to get a concrete result. How…
w3spi
  • 4,380
  • 9
  • 47
  • 80
-3
votes
2 answers

Basic Python - Extracting Strings

I am trying to extract what's between parenthesis (including parenthesis) recursively. This is my solution: def paren(txt): if txt[1] == ")": return '' if txt[0] == "(": if len(txt) > 2: return txt[1] + paren(txt[:1] + txt[2:]) …
Zee
  • 31
  • 3
-3
votes
2 answers

Parenthesis around AND OR

I needed some help in making sure I am using my parenthesis correctly around AND OR statements in SQL SERVER. SELECT DISTINCT * FROM Table WHERE yearmonth = 201404 AND (HasA = 1 OR HasB = 1 OR hasC = 1) AND (HasAX = 10 OR HasBX = 10 OR HasCX =…
data addicted
  • 69
  • 1
  • 11
-3
votes
4 answers

How to check for matching parentheses in Java?

For my homework assignment, we are supposed to use stacks to make a calculator using infix and postfix in java. While I am reading in the equations from the file, there are lots of parentheses. I am supposed to make sure they match up and have an…
Shark Surfer
  • 67
  • 1
  • 6
-4
votes
1 answer

How would i split up 2 values in parentheses in Python?

So, I'm working on a python script that will auto click at the coordinates of set pixels. I'm encountering an issue where I need to split up two values in normal parentheses. Example: (1023, 503) Is there any way to even split this up into two…
-4
votes
2 answers

Will parentheses make program slower?

I'm just wondering if using parentheses in Ruby makes a program slower. I know it's common to omit them, but for me, using parentheses increases readability.
-4
votes
3 answers

Order of operations not correct? (C++)

I was writing a small Least common multiple algorithm and encountered something I don't understand. This is the first and last part of the code: long a = 14159572; long b = 63967072; int rest = 4; long long ans; . . // Some other code here that is…
-4
votes
1 answer

parentheses balanced in C language

This is a parentheses balanced code. I submitted and got comment from my professor. "Your stack is supposed to grow and shrink dynamically to accommodate any number of characters. DO NOT USE scanf for %s, this is risky behavior and Dr. Adams does…
kimchistudent
  • 97
  • 2
  • 7
-4
votes
2 answers

C: Errors with Parentheses

So I'm writing a series of functions, and then I try to compile, I get errors talking about parentheses. I've looked over my code, and I can't find any mismatched parenthesis. Can anyone tell me what I'm doing wrong> int str_to_int(char* str) { …
metalhead696
  • 195
  • 2
  • 11
-4
votes
1 answer

unbalanced parenthesis error using re.search python

I have a list that I want to loop through (for trimtemp in trim) and see if it has any matches in a given string (modeltrim). The code runs fine most of the time however, every now and then it gives me the following error: Traceback (most recent…
jordanskis
  • 257
  • 1
  • 4
  • 11
-5
votes
2 answers

C++ code mandatory parenthesis

I read a piece of code written as for (kf=0; kfepsilonBed.GetElem(j,i,kf)); …
kiriloff
  • 25,609
  • 37
  • 148
  • 229
-6
votes
1 answer

How to create an algorithm that takes as input a propositional logic expression without parentheses and encloses the same in parentheses in Python

I'd like to create an algorithm that takes as input a propositional logic expression without parentheses and outputs the same expression enclosed in parentheses in all possible ways depending on the logical connectives present. For example, if I…
-6
votes
3 answers

I need to get rid of the parentheses around a number inside of a

I found a way to do it with jQuery but I need pure javascript I can put in