Skip to main content

Questions tagged [operators]

Operators are symbols that occur in nearly all programming and coding languages, used for performing calculations, comparisons, and assignments of data. Use this tag for any questions relating to operators, in any language, including things such as syntax, behaviour and use.

operators
Filter by
Sorted by
Tagged with
0 votes
1 answer
19 views

Why does the PHP spread operator in an Elasticsearch query return different results than hardcoding parts of the query?

I've got a problem that I'm not entirely sure I understand. I've got the following Elasticsearch query, written in PHP, with fuzziness matching hardcoded; this results in about an expected 1,500 ...
Martin Uildriks's user avatar
0 votes
0 answers
53 views

What does a caret and an equal sign (^=) do in Python? [duplicate]

I was looking at the solution to a Python problem, and in it was int ^= num I don't understand what it means. When I searched for it, I got a bunch of posts explaining what the caret sign does on its ...
Cool_Dude's user avatar
0 votes
1 answer
59 views

How to Implement operator-> for a Custom UniquePtr Class in C++? [duplicate]

I am trying to write my own implementation of unique_ptr in C++, and here is my UniquePtr header file: #include <iostream> template <typename T> class UniquePtr { T* ptr; public: ...
user25687822's user avatar
1 vote
1 answer
80 views

How does the arrow operator in haskell make sense in functions that take more than one parameter?

FYI: Second day into Haskell MRE (what the function does, does not matter): foo :: Int -> Int -> Int foo x y | x == y = x + y | x < y = x | x > y = y This is what ...
kesarling's user avatar
  • 2,102
0 votes
1 answer
61 views

How to parse search engine keywords input

I'm implementing a tool that lets users search for terms in texts. I'm currently focused on handling more complex input from the search. The operators I am looking to support are : | = OR & = AND ...
Equino's user avatar
  • 47
2 votes
1 answer
75 views

How do I parse Python-style chaining operators in Haskell using parsec?

In the project I'm currently working on, I construct the expression parser in parsec. The code is something like: opTable :: [[Operator Parser Expr]] opTable = [ -- ... [ InfixL $ ...
盛安安's user avatar
  • 1,191
2 votes
1 answer
46 views

Understanding Array comparison while using custom data types with numpy

i have a question regarding comparison with numpy arrays while using cusom data types. Here is my code: import numpy as np class Expr: def __add__(self, other): return Add(self, other) ...
Max Berktold's user avatar
-1 votes
1 answer
54 views

friend operator << and >> in base class without child class but still called

Why is the operators << and >> called in base class if they are defined as 'friend' when calling << and >> in child class? Code: #include <iostream> #include <memory&...
sticknycu's user avatar
  • 121
0 votes
1 answer
77 views

Use defined operators from base class in inherited class

Assume I have a base class class Vector { public: Vector(const std::vector<float> &elements); static Vector add(const Vector &v1, const Vector &v2); Vector Vector::...
vtx22's user avatar
  • 25
1 vote
1 answer
21 views

ComputeError with polars dataframe while trying to pass a column expressions in a simple shift() operation

Sorry, I'm starting out in Polars. Is there a way to achieve the same functionality of the shift(n) function where n is a dataframe variable. When I try: df = pl.DataFrame({ "a": [1, 2, ...
user23486287's user avatar
0 votes
0 answers
22 views

How do I define a custom method for @ operator? [duplicate]

Numpy uses the @ operator for matrix multiplication between two arrays. I have my own class for which I want to define a method using the @ operator. How should this be done? I define my own __add__, ...
johann's user avatar
  • 16
0 votes
1 answer
42 views

How to getline from txt file and check if it is correct with what the user inputed

I am creating a bank application. So far, I can create an account. After that, it encrypts the data like password and SSN. After that, it takes me to the login function where I have to enter my user ...
WillBeTheBestInTheFuture's user avatar
0 votes
1 answer
36 views

How to use otel collector to collect some CRD resources?

Does there are any solutions that I can use to collect resources for Operators, Helm Charts, CRD hierarchies and CD configurations via otel collector? All of them are not build-in resources for ...
Guangya Liu's user avatar
0 votes
0 answers
27 views

Airfllow: Having a Custom Sensor Operator inside of python operator

I have a dag task called check_file that is responsible to check the file in remote location. check_file = PythonOperator( task_id='check_file', python_callable=check_file, ...
adkharel's user avatar
0 votes
1 answer
37 views

Remove boilerplate code when writing operator overloads

When I made my vector3 struct I noticed the operator functions were almost identical to eachother vector3 vector3::operator+(float scalar) const { return vector3(x + scalar, y + scalar, z + ...
enies lobby's user avatar
2 votes
0 answers
70 views

How to cast to derived class type without dereferencing the base class pointer?

Background Hello, I am trying to create a way of type checking on casting between derived class types. To do so I want to inform the user when they cast to a type that might cause data loss. Having ...
TheBoomNL's user avatar
0 votes
0 answers
15 views

How to build a polymorphic cluster based on a virtual one within the class hierarchy operator method + and demonstrate the mechanism of late binding?

In the base class I defined this operator (I declared it as virtual in the header file): String String::operator+(String& other) { int newLength = getTrueSize() + other.getTrueSize() + 1; ...
user24509156's user avatar
0 votes
0 answers
91 views

OpenShift Operators clash over InstallModeType

OpenShift V4.12, have four operators installed in namespace openshift-operators, however they clash over there required InstallModeType. When the default global operator-group within the namespace is ...
timd's user avatar
  • 376
1 vote
2 answers
61 views

The "-" Operator in SQL where condition

I am encountering a rather peculiar syntax in MySQL, specifically the presence of a '-' symbol within the WHERE condition in the following query. SELECT users.id FROM users WHERE users....
dqqqq98's user avatar
  • 13
0 votes
0 answers
17 views

Can anyone tell me that how html operators will work in ckeditor?

& , < and > operators are not working. When i have entered these operators cursor moves at start of line bydefault. I have replaced these operators with others also but didn't work and also ...
Monika chibh's user avatar
-1 votes
2 answers
151 views

Is Observable's "viewof" really an operator? [closed]

I'm confused by Observable's use of the word "operator" in their documentation, and wondering whether they have misused it, or I'm simply not understanding. Observable has a special viewof ...
Steve Bennett's user avatar
-1 votes
1 answer
99 views

groovy find operator produce java.io.NotSerializableException: java.util.regex.Matcher

Im working in a pipeline with groovy and I found this problem with find operator where all solutions didn't work. after this code: stage('Get build artifacts') { def buildNumber = (params....
deconya's user avatar
  • 81
0 votes
0 answers
34 views

How to numerically solve the diffferential equation giving the ground states of a Bose-Einstein condensate?

I am trying to solve the differential equation giving the ground states of a Bose-Einstein Condensate in 2D. I need to solve it in C/C++. I have an equation that is as follows : (vn+1-vn)/dTau = 1/2* ...
Pascal Gicquel's user avatar
0 votes
0 answers
45 views

Prefix type operators in Scala?

Scala allows writing infix operators for types, just as for expressions: type ->[P,Q] = P => Q Making X -> Y equivalent to writing ->[X,Y]. I would like to have a unary prefix operator, ...
TrayMan's user avatar
  • 7,397
0 votes
3 answers
79 views

How to return integer part using backslash when dividing two decimals in Visual Basic

I am trying to divide two decimals and want to get the exact integer part of the result only using a\b. Consider the following example: Dim a, b As Integer a = 200 b = 2 ...
maponda1's user avatar
0 votes
0 answers
19 views

Why A = B = C not the same as A = B AND B = C AND C = A in MySQL Case When Statement? [duplicate]

Here is a table Numbers: +--+--+--+ |A |B |C | +--+--+--+ |1 |1 |1 | |1 |2 |1 | |2 |2 |2 | |3 |2 |1 | |3 |3 |3 | +--+--+--+ Now executing the query: SELECT CASE WHEN (A = B = C) THEN "Equal"...
Dhrumil Dave's user avatar
1 vote
1 answer
20 views

Why my OR operator doesn't work on XPATH? [duplicate]

I've tried both //th[text()="Seller Finanacing Available"]/following-sibling::td[text()="Yes" OR text()=""] and //th[text()="Seller Finanacing Available"]/...
Aminah Nuraini's user avatar
-2 votes
1 answer
56 views

Why is my or operator not working in my while loop [duplicate]

Im trying to use an or operator the the parameters of my while loop and its not working. import javax.swing.JOptionPane; public class Checkpoint203P5 { public static void main(String[] args){ ...
wayne's user avatar
  • 3
0 votes
1 answer
68 views

Does C++ guarantee shortcutting for compile time constants?

I have a compile-time condition, using std::conditional<cond, TypeA, TypeB>. In my case, the condition is a disjunction, along the lines of SimpleCondition<T>::value || ComplexCondition&...
Cort Ammon's user avatar
  • 10.6k
2 votes
1 answer
62 views

Why does calling a static method with only one colon not cause a parse error? [duplicate]

When calling the following code, I was surprised that a parse error was not thrown or other error given as this code does not look right. The colon in PHP has several uses, however, I've gone off the ...
SeanDowney's user avatar
  • 17.7k
1 vote
1 answer
85 views

I'm trying to test if a variable does not equal multiple values but I don't want very long code

I'm trying to make a for loop that ignores lower case vowels. There are 5 in total and I don't want to write 5 'and' statements, because what if I have 10 values I don't want to equal? I would have to ...
user23333929's user avatar
-1 votes
1 answer
51 views

Why does Python return 0 for this & operation?

I'm learning Python and messing around with operations when I tried >>> 14 & 16 0 >>> 0b1110 & 0b10000 0 In my head it would look like this: >>> 0b1110 & ...
neirad's user avatar
  • 3
0 votes
0 answers
78 views

Inaccurate results using mod operator in python [duplicate]

I'm having trouble in a condition i want in a if statement. I want to check if a variable(float type), like 0.9, is multiple of 0.1. I had this code: (t * dt) % 0.1 == 0 I've tried the modulo ...
mariami's user avatar
2 votes
1 answer
51 views

Attaching infix operators

Benefit of attaching objects (you can skip this) In a sourced script, it can be convenient to define our helper funcs like this: f <- function() print('hi') e <- new.env() assign("f", ...
antonio's user avatar
  • 10.9k
0 votes
1 answer
40 views

When to use append() and when the += operator in Python?

This is my first question on Stack Overflow. I want to add a new dictionary at the end of an existing list with multiple dictionaries (see example below): travel_log = [ { "country": &...
Carlotta Ferri's user avatar
0 votes
0 answers
38 views

Python example f"{heading:=^30}"

I ran across this in a basic Python tutorial (https://docs.python.org/3.10/tutorial/controlflow.html). The example is: >>> heading = "Centered string" >>> f"{heading:=...
user3765883's user avatar
0 votes
2 answers
55 views

Python script: upper bound of range not being included

I wrote this script: inpf = input('input file name:') lb = input('lower bound:') ub = input('upper bound:') with open(inpf, 'r') as f: contents = f.readlines() for i in contents: if lb ...
Drew's user avatar
  • 1
0 votes
1 answer
59 views

One liner for operation with two different operators

I have a bitflag enum EFlags. Given a condition I want to either remove a flag or add a flag. I have defined the operator |= to add a flag and &= to remove a flag. For example, let us say the ...
Eshy's user avatar
  • 351
-1 votes
1 answer
85 views

Number raised to 2, 3, and 4 [duplicate]

I have written the following simple C++ program to output the powers of a number input by the user to indices 2, 3, and 4: int a = 0; cin >> a; int a2 = a * a; cout << "\n" &...
Ali Kamel Ali's user avatar
-1 votes
1 answer
82 views

PHP - Why does division operation causes loop to skip rows of data

Completely stumped by this one. I have some code that pulls rows from a database and attempts to process them as part of a PHP while() loop. Here's the basic code: $i = 1; while (list($thisScoreID, $...
Eric Brockway's user avatar
1 vote
4 answers
156 views

Cannot use spread inside conditional operator [duplicate]

Suppose the following: const arr = [1, 2, 3]; const insertValues = [-1, 0]; const condition = true; arr.splice(0, 0, condition ? ...insertValues : insertValues); This throws a syntax error: ...
Mike K's user avatar
  • 6,243
0 votes
0 answers
80 views

What is the <:0:> operator in c++? [duplicate]

I recently found a strange operator in the c++ codebase of my company. There it is: // make the output visible on the console std::cout.rdbuf()<:0:>.pubsync(); What does the "<:...
DeadMaX's user avatar
  • 11
0 votes
1 answer
70 views

Concatenate String and Is Operator

I do not understand why this code does throw a nullref. I think it has something to do with the priority of the 'plus' operator and the 'is' operator but I am really not sure why. return "...
jeb's user avatar
  • 1,182
-1 votes
1 answer
42 views

Combining python "in" and "==" operator has confusing behavior [duplicate]

A buddy of mine is learning python and I saw an odd thing he did with his code: if ch in input[index] == test[index]) Obviously there's some context missing for that fragment, but interestingly, that ...
Christian Baker's user avatar
1 vote
2 answers
125 views

Freemarker equivalent of typescript optional chaining "?"

Typescript has a nice operator ? (called optional chaining) that check empty attributes in chains of dots. Example x?.y?.w?.z means (more or less) if (x !== undefined && x !== null && ...
luca.vercelli's user avatar
-2 votes
2 answers
134 views

Make easely a sub array from an array

Check this c/c++ code, but just pay atention to the use of "&" operator and the array operations into the function. Its ok to pass an array like that?, will be any invalid access problem ...
Cebo's user avatar
  • 25
0 votes
1 answer
55 views

Using assignment operators in Dart

void main() { var a=10; var b=2; var toplam=a+=b; var fark=a-=b; var carpim=a*=b; var bolme=a/=b; print("$toplam"); print("$fark"); print("$carpim"); ...
Zeynep Baysoy's user avatar
1 vote
0 answers
44 views

Operator Associativity Test vs Operand Evaluation Order

I am trying to write a simple code structure that verifies whether the && operator in a language (not a specific language, so I can't get help of truthy/falsy values) is left-associative or ...
pnguib's user avatar
  • 53
1 vote
1 answer
56 views

Dictionary subscript or operator which adds a specified "default" value if key doesn't exist is Swift?

I need to write something like the following: var dict = [SomeEnum: SomeObject]() var someValue: SomeObject! = dict[.case1] if someValue == nil { someValue = someDefaultValue dict[.case1] = ...
Gargo's user avatar
  • 1,330
0 votes
1 answer
42 views

Reading the values out of an expression string, while keeping the formula intact

I have some code with mathematical operations, and I'm trying to make them easier to read and debug. But a very particular case is becoming complex, here's an example: public int val1=1; public int ...
desiredness's user avatar

1
2 3 4 5
157