binary-operators Questions

11

Solved

I've been attempting to learn C in my spare time, and other languages (C#, Java, etc.) have the same concept (and often the same operators)... At a core level, what does bit-shifting (<<, &gt...

1

Solved

In Haskell, we can write print $ abs $ 3 - 5 using $ . In F#, we can write printfn "%d" << abs <| 3 - 5 However, in many cases in F#, it would be also useful to have the same fun...
Drifter asked 7/9, 2022 at 19:14

5

Solved

In JavaScript we can build a string with other types using reducer (e.g. num to string): const string = [1,2,3,4,5].reduce((acc,e) => acc += e, "") //"12345" In Java, this p...
Ricer asked 30/3, 2021 at 5:32

6

Solved

I wonder if it's possible to store lambdas in some container, for ex. ArrayList or HashMap. I want to change that code: public enum OPCODE implements BinaryOperator<Integer> { MOV((x, y) -&...

2

Motivation I am trying to create my first real deal program in Rust for a school project (not a requirement..I just have been fascinated by Rust and decided that I'm going to take the plunge). The ...
Woody asked 12/12, 2019 at 8:20

2

Solved

I'm trying to replace the common switch for arithmetical operations by BinaryOperator functional interface. The base method is: private static int computeOne(int res, String operand, String ope...
Tardy asked 6/4, 2018 at 19:26

5

Solved

Given a matrix of n rows and m columns of 1's and 0's, it is required to find out the number of pairs of rows that can be selected so that their OR is 11111....m times. Example: 1 0 1 0 1 0 1 0 ...
Pedicular asked 3/6, 2017 at 20:47

3

Solved

As I was using bit-shifting on byte, I notice I was getting weird results when using unsigned right shift (>>>). With int, both right shift (signed:>> and unsigned:>>>) beha...
Antilles asked 6/4, 2016 at 14:59

3

Solved

So, I'm learning Haskell at the moment, and I would like to confirm or debunk my understanding of monoid. What I figured out from reading CIS194 course is that monoid is basically "API" for defi...
Standup asked 2/9, 2015 at 17:17

1

Solved

The Rust Reference presently says the following about the as operator: 7.2.12.5 Type cast expressions A type cast expression is denoted with the binary operator as. Executing an as express...
Politburo asked 19/8, 2015 at 18:0

2

Solved

I am confused with a question that I saw in a c++ test. The code is here: #include <iostream> using namespace std; class Int { public: int v; Int(int a) { v = a; } Int &operator[](i...

1

Solved

I have by pure chance discovered that the C# compiler turns this method: static bool IsNotNull(object obj) { return obj != null; } …into this CIL: .method private hidebysig static bool IsNotNu...
Repent asked 28/2, 2015 at 12:43

2

I'm trying to refactor part of a pathfinding algorithm I had that used pointers to not use pointers. Unfortunately I'm not that knowledgable about references. I get the error: Invalid operands to b...
Finlay asked 22/1, 2015 at 2:19

3

Solved

Okay, so after going through the tutorials on numpy's structured arrays I am able to create some simple examples: from numpy import array, ones names=['scalar', '1d-array', '2d-array'] formats=['f...
Maintopmast asked 13/10, 2014 at 21:25

2

Solved

I am currently reading the O'Reilly Java 8 Lambdas, it is a really good book. I came across with a example like this. I have a private final BiFunction<StringBuilder,String,StringBuilder>accu...
Misdemean asked 1/6, 2014 at 14:29

2

Solved

I can see why $a = new ArrayObject(); $a['ID'] = 42; $b = &$a['ID']; $c = $a; $c['ID'] = 37; echo $a['ID']."\n"; echo $b."\n"; echo $c['ID']."\n"; outputs 37, 42, 37 while $a = new ArrayOb...
Ellissa asked 20/5, 2013 at 23:43

1

Solved

I am creating a parse tree that will contain expressions similar to 3 - 4 * 8 or 8 * -5 or -(10 * 1) I need a way to distinguish between the unary and binary minus. The way my grammar is g...

5

Solved

I recently came across some functions where you can pass multiple enums like this: myFunction(One | Two); Since I think this is a really elegant way I tried to implement something like that myse...
Genome asked 9/12, 2009 at 13:53

4

Solved

Could someone explain to me why the mask is not shifted to the right at all? You can use anything in place of that 1 and the result will be the same. unsigned mask = ~0 >> 1; printf("%u\n", ...
Logarithmic asked 24/2, 2009 at 22:59
1

© 2022 - 2024 — McMap. All rights reserved.