citykid
citykid

Reputation: 11070

Is it possible to define the ** operator in F#

let (**) ls1 ls2 = List.intersect ls1 ls2

does not work because (**) is considered a comment. Is there any escape possibility?

Upvotes: 4

Views: 77

Answers (1)

Fyodor Soikin
Fyodor Soikin

Reputation: 80744

You can add whitespace inside the parentheses, like this:

let ( ** ) ls1 ls2 = List.intersect ls1 ls2

Keep in mind, however, that ** is a standard F# operator for "power":

2 ** 3 = 8

So if you redefine it like this in the global context, you will not be able to use it in the "power" sense.

Upvotes: 7

Related Questions