Last active
August 29, 2015 14:23
-
-
Save bratsche/ee81699a6960fb3b1233 to your computer and use it in GitHub Desktop.
Seq.findIndex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
F# Interactive for F# 3.1 (Open Source Edition) | |
Freely distributed under the Apache 2.0 Open Source License | |
For help type #help;; | |
> let scale1 = seq { -0.5 .. 0.1 .. 0.5 } ;; | |
val scale1 : seq<float> | |
> scale1 |> Seq.toArray ;; | |
val it : float [] = | |
[|-0.5; -0.4; -0.3; -0.2; -0.1; 0.0; 0.1; 0.2; 0.3; 0.4; 0.5|] | |
> scale1 |> Seq.findIndex (fun e -> e = -0.5) ;; | |
val it : int = 0 | |
> scale1 |> Seq.findIndex (fun e -> e = -0.4) ;; | |
val it : int = 1 | |
> scale1 |> Seq.findIndex (fun e -> e = -0.3) ;; | |
val it : int = 2 | |
> scale1 |> Seq.findIndex (fun e -> e = -0.2) ;; | |
System.Collections.Generic.KeyNotFoundException: Exception of type 'System.Collections.Generic.KeyNotFoundException' was thrown. | |
at Microsoft.FSharp.Collections.SeqModule.loop@1161-16[Double] (Microsoft.FSharp.Core.FSharpFunc`2 p, IEnumerator`1 ie, Int32 i) [0x00000] in <filename unknown>:0 | |
at Microsoft.FSharp.Collections.SeqModule.FindIndex[Double] (Microsoft.FSharp.Core.FSharpFunc`2 predicate, IEnumerable`1 source) [0x00000] in <filename unknown>:0 | |
at <StartupCode$FSI_0007>.$FSI_0007.main@ () [0x00000] in <filename unknown>:0 | |
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) | |
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 | |
Stopped due to error | |
> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment