infix-operator Questions

6

Is it possible to define my own infix function/operator in CoffeeScript (or in pure JavaScript)? e.g. I want to call a foo b or a `foo` b instead of a.foo b or, when foo is global function...

1

Solved

In Raku, infix operators can be used like functions, e.g.: 1 + 2 ; # 3 infix:<+>(1, 2) ; # 3 [+] 1, 2 ; # 3 Prefix operators can be used with method-like syntax (methodop): -1 ; # -1 1.:<...
Tana asked 15/7, 2021 at 18:47

1

In F# it is not uncommon to declare infix operators for binary operators. But how are they represented if we try to use them in C# Since there are no way of declaring infix operators in C#? Toy Exa...
Geis asked 10/12, 2020 at 6:24

1

Solved

I was trying to make Python 3-style assignment unpacking possible in R (e.g., a, *b, c = [1,2,3], "C"), and although I got so close (you can check out my code here), I ultimately ran into...
Participle asked 29/6, 2020 at 19:20

1

Solved

In both Kotlin REPL and Kotlin/JVM: -1 ushr 4 evaluates to 268435455 -1.ushr(4) evaluates to 0 The first one is correct, as -1 is 0xFFFFFFFF, so 0x0FFFFFFF is 268435455, but what makes the seco...
Interregnum asked 28/6, 2019 at 13:29

1

Solved

A little bit of context first... I've written an infix function that in essence replaces the idiom x[[length(x) +1]] <- y ..or simply x <- append(x, y) for vectors. Here it is: `%+=%` &l...
Hesperian asked 12/12, 2018 at 13:42

1

Solved

How do I convert negative numbers from infix to postfix ? Suppose I have a expression a = - b - (-c-d) In some places I read that you can parathesize the negative numbers like a = (-b) - (-c-...
Unfasten asked 21/10, 2017 at 7:56

1

Solved

Consider two data declarations: {-# LANGUAGE GADTs #-} data X = Int `Y` Int deriving Show data Z where W :: Int -> Int -> Z deriving Show main = do print (1 `Y` 2) print (3 `W` 4) Ru...
Geotropism asked 23/6, 2017 at 20:8

1

Solved

Why isn't 〉 allowed as an infix operator in Haskell? GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help Prelude> :{ infixr 6 〉 (〉) :: Int -> (Int -> (Int)) a 〉 b = a + 2*b :}...
Impignorate asked 21/6, 2017 at 22:36

1

Solved

It is easy to introduce new infix operators in C++ // User-defined infix operator framework template <typename LeftOperand, typename Operation> struct LeftHelper { const LeftOperand& l...
Ragland asked 1/4, 2016 at 12:42

1

I love this syntax in Objective-C, where a question mark and colon let you use a backup value: NSString const name = [self getName] ?: @"backup"; and I want to use the same in Swift, but I...
Geronto asked 25/3, 2016 at 15:20

1

For example, this does not type check \cons nil -> 5 `cons` 3 `cons` nil nor does this \(#) -> 5 # 3 # nil Although both of these do \cons nil -> 5 `cons` nil \(#) nil -> 5 # nil...
Jumbala asked 5/12, 2015 at 18:14

2

Solved

Looking at the Haskell Servant package, there is an initial example of defining a webservice API as: -- GET /date type MyAPI = "date" :> Get '[JSON] Date -- GET /time/:tz :<|> "time" :...
Monitory asked 29/10, 2015 at 4:58

1

Solved

I'm trying to create a more parsimonious version of this solution, which entails specifying the RHS of a formula in the form d1 + d1:d2. Given that * in the context of a formula is a pithy stand-i...
Colquitt asked 16/9, 2015 at 19:8

1

Solved

Why is f <$> g <$> x equivalent to (f . g) <$> x although <$> is not right-associative? (This kind of equivalence is valid in a popular idiom with plain $, but currently $ ...

2

Solved

In the Haskell 98 report, I found this: The syntax for Haskell type expressions is given above. Just as data values are built using data constructors, type values are built from type constructor...
Trichomonad asked 4/5, 2015 at 20:12

1

Solved

All of the following expressions get evaluated without mishap: (+2) 1 -- 3 (*2) 1 -- 2 ((-)2) 1 -- 1 (2-) 1 -- 1 (/2) 1 -- 0.5 (2/) 1 -- 2.0 but not this one: (-2) 1 -- the inferred type...
Omura asked 6/3, 2015 at 0:20

2

Solved

I want to use ** to overload an exponent function. I works if I use something like "^" but the python way of doing is ** and I would like to use that with Swift. Any way to do that? error: Opera...
Desk asked 6/6, 2014 at 14:53

3

Solved

Is there a way to make applicative uses of <$> and <*> look nice when dealing with infix operators? I think that ((++) <$> a <*> ((++) <$> b <*> c )) looks mu...
Howard asked 2/10, 2012 at 2:35

1

Solved

I can see the type of an infix operator in GHCi with :t like so: >:t (.) (.) :: (b -> c) -> (a -> b) -> a -> c How can i see the operator precedence in GHCi? is that possible? ...
Alicealicea asked 2/9, 2012 at 18:55

1

Solved

I am working on a DSL and I've run into a problem with using methods as infix operators in a chain. I'll just try to explain it with some code. I have a trait Term and case classes Literal and Vari...
Eileneeilis asked 5/5, 2011 at 21:1

3

Solved

I'm trying to understand the implementation of Lists in Scala. In particular I'm trying to get my head around how you can write match expressions using an infix operator, for example: a match { c...
Dino asked 20/6, 2009 at 18:45
1

© 2022 - 2024 — McMap. All rights reserved.