Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does F# has a function to tell if a list contains a specific value? [duplicate]

Tags:

f#

contain

Haskell has "elem" predicate to tell like:

Prelude> 5 `elem` [2,4..10]
False

In F#, how to conveniently tell whether a value is in a list, or array, or seq or map, or dictionary?

like image 418
vik santata Avatar asked Feb 02 '16 07:02

vik santata


People also ask

What does f say about f and f?

f, f′ and f″ Since (f′)′=f″, when f′ is increasing, f″ is positive. Similarly, when the slopes of tangent lines are decreasing, i.e. when f′ is decreasing, the function is concave down, as you can see in the second two graphs below. Since (f′)′=f″, when f′ is decreasing, f″ is negative.

What does ∘ mean in math?

The ∘ symbol denotes a composite function - it looks similar to the multiplication symbol, ⋅, but does not mean the same thing. (f ∘ g)(x) is the same thing as f(g(x)). (f ∘ g)(x) is not the same thing as (g ∘ f)(x). (g ∘ f)(x) is the same thing as g(f(x)), which will often be different than f(g(x)).

What does ↦ mean in math?

A maplet or maplet arrow (symbol: ↦, commonly pronounced "maps to") is a symbol consisting of a vertical line with a rightward-facing arrow. It is used in mathematics and in computer science to denote functions (the expression x ↦ y is also called a maplet).


1 Answers

In F# it is

List.contains <element> <list>

Example:

List.contains 5 [2..2..10]

-->

val it : bool = false

contains is also defined for the other container types.

like image 124
BitTickler Avatar answered Sep 21 '22 07:09

BitTickler