# \#operator

**URL:** https://discourse.julialang.org/tag/operator/1053.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Custom binary operators (with custom name)?](https://discourse.julialang.org/t/custom-binary-operators-with-custom-name/134141)

<div class="topic-metadata">

**Author:** [@sylvaticus](https://discourse.julialang.org/u/sylvaticus)\
**Replies:** 9\
**Last updated:** [December 1, 2025, 5:42am UTC](https://discourse.julialang.org/t/custom-binary-operators-with-custom-name/134141 "2025-12-01T05:42:16Z")

</div>

Aside +, \*, etc. is there a way to define my own binary operator, say Foo such that I can write something like: Foo(x,y) = \[some funny op using x and y\] ((x Foo b) Foo c) ....

---

## [How to implement a FFT based 2D laplacian in SciMLOperators.jl?](https://discourse.julialang.org/t/how-to-implement-a-fft-based-2d-laplacian-in-scimloperators-jl/132143)

<div class="topic-metadata">

**Author:** [@marcsgil](https://discourse.julialang.org/u/marcsgil)\
**Replies:** 1\
**Last updated:** [September 30, 2025, 4:51pm UTC](https://discourse.julialang.org/t/how-to-implement-a-fft-based-2d-laplacian-in-scimloperators-jl/132143 "2025-09-30T16:51:58Z")

</div>

Hello! I was trying to implement a FFT based 2D laplacian in SciMLOperators.jl, but I ran into some trouble. Here is my attempt, which was based in this example in the docs: using SciMLOperators using LinearAlgebra, FF…

---

## [Solving Optimization of Least Squares Term with Quadratic Term with Memory Infeasible Matrix](https://discourse.julialang.org/t/solving-optimization-of-least-squares-term-with-quadratic-term-with-memory-infeasible-matrix/132599)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 2\
**Last updated:** [September 24, 2025, 2:41pm UTC](https://discourse.julialang.org/t/solving-optimization-of-least-squares-term-with-quadratic-term-with-memory-infeasible-matrix/132599 "2025-09-24T14:41:15Z")

</div>

I want to solve: \\arg \\min\_{\\boldsymbol{x}} \\frac{\\lambda}{2} \\boldsymbol{x}^{T} \\boldsymbol{E}^{T} \\boldsymbol{K} \\boldsymbol{E} \\boldsymbol{x} + \\frac{\\rho}{2} {\\left\\| \\boldsymbol{A} \\boldsymbol{x} - \\boldsymbol{y} …

---

## [Is it possible to define '+' operator for string as '\*' do for them?](https://discourse.julialang.org/t/is-it-possible-to-define-operator-for-string-as-do-for-them/131835)

<div class="topic-metadata">

**Author:** [@psalm1750](https://discourse.julialang.org/u/psalm1750)\
**Replies:** 12\
**Last updated:** [August 26, 2025, 1:29pm UTC](https://discourse.julialang.org/t/is-it-possible-to-define-operator-for-string-as-do-for-them/131835 "2025-08-26T13:29:30Z")

</div>

I’d like to use ‘+’ operator for string concatenation. but it is ‘\*’ in Julia. If possible I’d like to define ‘+’ as alias of ‘\*’ if opland are strings. because some insufficient definition cause some side effect. Th…

---

## [Why \`∋\` (\`\\ni\`) is not a method of \`contains\`?](https://discourse.julialang.org/t/why-ni-is-not-a-method-of-contains/128748)

<div class="topic-metadata">

**Author:** [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Replies:** 3\
**Last updated:** [May 6, 2025, 2:30pm UTC](https://discourse.julialang.org/t/why-ni-is-not-a-method-of-contains/128748 "2025-05-06T14:30:15Z")

</div>

in(x) is a convenient function generator to check whether other variables are contained in x (e.g. for filtering). I was looking for a generator of functions that do the opposite (check if other variables contain x), and…

---

## [Seemingly extension of example in SciMLOperators doesn't work](https://discourse.julialang.org/t/seemingly-extension-of-example-in-scimloperators-doesnt-work/127241)

<div class="topic-metadata">

**Author:** [@Veenty](https://discourse.julialang.org/u/Veenty)\
**Replies:** 1\
**Last updated:** [March 23, 2025, 6:46am UTC](https://discourse.julialang.org/t/seemingly-extension-of-example-in-scimloperators-doesnt-work/127241 "2025-03-23T06:46:10Z")

</div>

JUst following the tutorial I would like to be able to define operator L6, as follows N = 4 f = (u, p, t) -\> u .\* u M = MatrixOperator(rand(N, N)) D = DiagonalOperator(rand(N)) F = FunctionOperator(f, zeros(N), zeros(…

---

## [If in === ∈, why does .∈ work but .in fails with a ParseError?](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464)

<div class="topic-metadata">

**Author:** [@Matheus](https://discourse.julialang.org/u/Matheus)\
**Replies:** 5\
**Last updated:** [February 2, 2025, 1:02pm UTC](https://discourse.julialang.org/t/if-in-why-does-work-but-in-fails-with-a-parseerror/125464 "2025-02-02T13:02:59Z")

</div>

Hello everyone, I’m trying to understand the following behavior regarding in and ∈ (I guess they’re called operators?). While they are functionally identical (in === ∈ returns true), they behave differently when used wi…

---

## [Coding style in unary operator overloading](https://discourse.julialang.org/t/coding-style-in-unary-operator-overloading/123888)

<div class="topic-metadata">

**Author:** [@greatpet](https://discourse.julialang.org/u/greatpet)\
**Replies:** 6\
**Last updated:** [December 17, 2024, 10:42am UTC](https://discourse.julialang.org/t/coding-style-in-unary-operator-overloading/123888 "2024-12-17T10:42:09Z")

</div>

Is there a reason to prefer one of the following two options? Option 1: Base.:-(a::MyType) = MyType(-a.data) Option 2: import Base.- -(a::MyType) = MyType(-a.data)

---

## [Truth values, precedence and arithmetic operators](https://discourse.julialang.org/t/truth-values-precedence-and-arithmetic-operators/122200)

<div class="topic-metadata">

**Author:** [@martin\_sanchez](https://discourse.julialang.org/u/martin_sanchez)\
**Replies:** 3\
**Last updated:** [November 3, 2024, 7:40pm UTC](https://discourse.julialang.org/t/truth-values-precedence-and-arithmetic-operators/122200 "2024-11-03T19:40:15Z")

</div>

While making a code, I had the following condition to throw an error: n\<0 | !isa(n,Integer) For n=3.0, the code was giving false. Though it took me a while, I now understand that “|” takes precedence. Even though, in t…

---

## [Overloading \`^\`](https://discourse.julialang.org/t/overloading/119723)

<div class="topic-metadata">

**Author:** [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Replies:** 2\
**Last updated:** [September 23, 2024, 2:49am UTC](https://discourse.julialang.org/t/overloading/119723 "2024-09-23T02:49:33Z")

</div>

struct S x end Base.:(^)(s::S, p) = S(s.x ^ p) S(1) ^ -2.0 S(1) ^ -2 # ERROR: MethodError: no method matching inv(::S) It looks like you can not completely define ^ for a type, without defining a multiplicative inverse i…

---

## [Update Vector with dot Operator - Different Behavior when using Vector and Other Types](https://discourse.julialang.org/t/update-vector-with-dot-operator-different-behavior-when-using-vector-and-other-types/116138)

<div class="topic-metadata">

**Author:** [@Andy\_Zhang](https://discourse.julialang.org/u/Andy_Zhang)\
**Replies:** 1\
**Last updated:** [June 24, 2024, 12:38pm UTC](https://discourse.julialang.org/t/update-vector-with-dot-operator-different-behavior-when-using-vector-and-other-types/116138 "2024-06-24T12:38:10Z")

</div>

Here is a piece of code: v1 = \[2, 3, 5, 7, 11, 13, 17\] @show v1 v1\[1:3\] = \[1, 2, 3\] @show v1 v1\[1:3\] .= 0 @show v1 v1\[1:3\] .= \[4, 5, 6\] @show v1 v1\[1:3\] .= "1" Output: v1 = \[2, 3, 5, 7, 11, 13, 17\] v1 = \[1, 2, 3, 7, 1…

---

## [Show operator precedence?](https://discourse.julialang.org/t/show-operator-precedence/115143)

<div class="topic-metadata">

**Author:** [@Ken\_Williams](https://discourse.julialang.org/u/Ken_Williams)\
**Replies:** 9\
**Last updated:** [June 4, 2024, 8:22pm UTC](https://discourse.julialang.org/t/show-operator-precedence/115143 "2024-06-04T20:22:28Z")

</div>

In the old days, I used to use a handy utility every once in a while to show how the parser interprets operator precedence: % perl -MO=Deparse,-p -e '$x \< 3 && $y \< 7' (($x \< 3) and ($y \< 7)); I’ve always found this a…

---

## [How to Use Operator Overloading with Optional Arguments in Julia](https://discourse.julialang.org/t/how-to-use-operator-overloading-with-optional-arguments-in-julia/114375)

<div class="topic-metadata">

**Author:** [@Akhil\_Akkapelli](https://discourse.julialang.org/u/Akhil_Akkapelli)\
**Replies:** 2\
**Last updated:** [May 16, 2024, 8:56pm UTC](https://discourse.julialang.org/t/how-to-use-operator-overloading-with-optional-arguments-in-julia/114375 "2024-05-16T20:56:44Z")

</div>

I’m working on a Julia project and I’ve defined a custom function with operator overloading. My function, which I’ve defined using the | operator, initializes a matrix of Box objects with properties derived from a parent…

---

## [Technical term for "operator inference" related to multiple dispatch](https://discourse.julialang.org/t/technical-term-for-operator-inference-related-to-multiple-dispatch/114109)

<div class="topic-metadata">

**Author:** [@younes](https://discourse.julialang.org/u/younes)\
**Replies:** 5\
**Last updated:** [May 10, 2024, 5:19pm UTC](https://discourse.julialang.org/t/technical-term-for-operator-inference-related-to-multiple-dispatch/114109 "2024-05-10T17:19:45Z")

</div>

I have defined the operator \< for my custom type Person: begin struct Person name::String age::Int end import Base: \< function \<(a::Person, b::Person)::Bool return a.age \< b.age end # Example …

---

## [Implementing Laplacian operator acting on a 2D array](https://discourse.julialang.org/t/implementing-laplacian-operator-acting-on-a-2d-array/111615)

<div class="topic-metadata">

**Author:** [@matt1](https://discourse.julialang.org/u/matt1)\
**Replies:** 6\
**Last updated:** [March 18, 2024, 5:41pm UTC](https://discourse.julialang.org/t/implementing-laplacian-operator-acting-on-a-2d-array/111615 "2024-03-18T17:41:03Z")

</div>

Hello, I’m interested in implementing the laplacian operator \\nabla^2=\\partial\_x^2+\\partial\_y^2, such that I can apply it to a matrix A\_{ij} and obtain the corresponding matrix: B\_{ij}=(\\nabla^2A)\_{i,j}. For example, th…

---

## [What happened to the \`..\` operator?](https://discourse.julialang.org/t/what-happened-to-the-operator/107224)

<div class="topic-metadata">

**Author:** [@DanDoe](https://discourse.julialang.org/u/DanDoe)\
**Replies:** 7\
**Last updated:** [December 6, 2023, 9:33pm UTC](https://discourse.julialang.org/t/what-happened-to-the-operator/107224 "2023-12-06T21:33:51Z")

</div>

I was trying the example from Makie for a Streamplot which involves the .. operator which is listed as an operator in the docs. However, on Julia 1.9.4 I receive julia\> 1..42 ERROR: UndefVarError: \`..\` not defined Stac…

---

## [Why ~ can not broadcast?](https://discourse.julialang.org/t/why-can-not-broadcast/106290)

<div class="topic-metadata">

**Author:** [@zhpf0530](https://discourse.julialang.org/u/zhpf0530)\
**Replies:** 2\
**Last updated:** [November 16, 2023, 3:16am UTC](https://discourse.julialang.org/t/why-can-not-broadcast/106290 "2023-11-16T03:16:00Z")

</div>

why ~ can not broadcast? a=randn(10) b=a.\>0 ~.b is wrong ~b is wrong map(~,b) is right.

---

## [\[SciMLOperators\] Idiomatic way to define a stateful FunctionOperator](https://discourse.julialang.org/t/scimloperators-idiomatic-way-to-define-a-stateful-functionoperator/97821)

<div class="topic-metadata">

**Author:** [@sbrisard](https://discourse.julialang.org/u/sbrisard)\
**Replies:** 0\
**Last updated:** [April 23, 2023, 4:06pm UTC](https://discourse.julialang.org/t/scimloperators-idiomatic-way-to-define-a-stateful-functionoperator/97821 "2023-04-23T16:06:03Z")

</div>

Hi, I’m trying to implement the 2D laplacian of a scalar field as a SciMLOperators.FunctionOperator, using centered finite differences. The op function needs to know the physical size of the grid (Lx, Ly) as well as the…

---

## [About the implementation of SciMLOperators.FunctionOperator](https://discourse.julialang.org/t/about-the-implementation-of-scimloperators-functionoperator/93738)

<div class="topic-metadata">

**Author:** [@sbrisard](https://discourse.julialang.org/u/sbrisard)\
**Replies:** 8\
**Last updated:** [February 11, 2023, 10:30am UTC](https://discourse.julialang.org/t/about-the-implementation-of-scimloperators-functionoperator/93738 "2023-02-11T10:30:26Z")

</div>

I am looking into SciMLOperators to define convolution linear operators. I was wondering why FunctionOperator requires prototypes of the input and output. Would the sizes not be sufficient? Also, it seems to me that t…

---

## [UndefVarError: .\* not defined when grouping with DataframesMeta](https://discourse.julialang.org/t/undefvarerror-not-defined-when-grouping-with-dataframesmeta/93115)

<div class="topic-metadata">

**Author:** [@a.frist](https://discourse.julialang.org/u/a.frist)\
**Replies:** 5\
**Last updated:** [January 28, 2023, 11:45pm UTC](https://discourse.julialang.org/t/undefvarerror-not-defined-when-grouping-with-dataframesmeta/93115 "2023-01-28T23:45:38Z")

</div>

Hello all, I ran into a problem when running a Julia script. The following code produces an error: UndefVarError: .\* not defined The offending Code: group = groupby(my\_dataframe, \[:COLUMN\_1, :COLUMN\_2\]) bet…

---

## [Why can't I combine a macro call with a comparison operator?](https://discourse.julialang.org/t/why-cant-i-combine-a-macro-call-with-a-comparison-operator/92493)

<div class="topic-metadata">

**Author:** [@veddox](https://discourse.julialang.org/u/veddox)\
**Replies:** 5\
**Last updated:** [January 5, 2023, 6:13am UTC](https://discourse.julialang.org/t/why-cant-i-combine-a-macro-call-with-a-comparison-operator/92493 "2023-01-05T06:13:37Z")

</div>

To save myself a bit of typing, I have created a wrapper macro around a function in my model, to be used in a specific context: macro landcover() :(landcover($(esc(:pos)), $(esc(:model)))) end I want to be able to …

---

## [.! operator not filtering missings values](https://discourse.julialang.org/t/operator-not-filtering-missings-values/82198)

<div class="topic-metadata">

**Author:** [@jcbritobr](https://discourse.julialang.org/u/jcbritobr)\
**Replies:** 1\
**Last updated:** [June 3, 2022, 3:18pm UTC](https://discourse.julialang.org/t/operator-not-filtering-missings-values/82198 "2022-06-03T15:18:22Z")

</div>

Hello, good afternonn, Why is not this code filtering off the missing values in their respective fields? All the array values are 1(true), even that Price and Grade has missing values. rowsToKeep = .!(ismissing.(data.…
