41 people like it.
Like the snippet!
LinkedList extensions
LinkedList functional extension providing find and findi higher order functions that take a predicate function.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
|
[<RequireQualifiedAccess>]
module LinkedList =
open System.Collections.Generic
let empty<'a> = LinkedList<'a>()
let ofSeq<'a> (xs:'a seq) = LinkedList<'a>(xs)
let find (f:'a->bool) (xs:LinkedList<'a>) =
let node = ref xs.First
while !node <> null && not <| f((!node).Value) do
node := (!node).Next
!node
let findi (f:int->'a->bool) (xs:LinkedList<'a>) =
let node = ref xs.First
let i = ref 0
while !node <> null && not <| f (!i) (!node).Value do
incr i; node := (!node).Next
if !node = null then -1 else !i
let nth n (xs:LinkedList<'a>) =
if n >= xs.Count then
let message = "The input sequence has an insufficient number of elements."
raise <| new System.ArgumentException(message,paramName="n")
let node = ref xs.First
for i = 1 to n do node := (!node).Next
!node
|
Multiple items
type RequireQualifiedAccessAttribute =
inherit Attribute
new : unit -> RequireQualifiedAccessAttribute
Full name: Microsoft.FSharp.Core.RequireQualifiedAccessAttribute
--------------------
new : unit -> RequireQualifiedAccessAttribute
module LinkedList
from Script
namespace System
namespace System.Collections
namespace System.Collections.Generic
val empty<'a> : LinkedList<'a>
Full name: Script.LinkedList.empty
Multiple items
type LinkedList<'T> =
new : unit -> LinkedList<'T> + 1 overload
member AddAfter : node:LinkedListNode<'T> * value:'T -> LinkedListNode<'T> + 1 overload
member AddBefore : node:LinkedListNode<'T> * value:'T -> LinkedListNode<'T> + 1 overload
member AddFirst : value:'T -> LinkedListNode<'T> + 1 overload
member AddLast : value:'T -> LinkedListNode<'T> + 1 overload
member Clear : unit -> unit
member Contains : value:'T -> bool
member CopyTo : array:'T[] * index:int -> unit
member Count : int
member Find : value:'T -> LinkedListNode<'T>
...
nested type Enumerator
Full name: System.Collections.Generic.LinkedList<_>
--------------------
LinkedList() : unit
LinkedList(collection: IEnumerable<'T>) : unit
val ofSeq : xs:seq<'a> -> LinkedList<'a>
Full name: Script.LinkedList.ofSeq
val xs : seq<'a>
Multiple items
val seq : sequence:seq<'T> -> seq<'T>
Full name: Microsoft.FSharp.Core.Operators.seq
--------------------
type seq<'T> = IEnumerable<'T>
Full name: Microsoft.FSharp.Collections.seq<_>
val find : f:('a -> bool) -> xs:LinkedList<'a> -> LinkedListNode<'a>
Full name: Script.LinkedList.find
val f : ('a -> bool)
type bool = System.Boolean
Full name: Microsoft.FSharp.Core.bool
val xs : LinkedList<'a>
val node : LinkedListNode<'a> ref
Multiple items
val ref : value:'T -> 'T ref
Full name: Microsoft.FSharp.Core.Operators.ref
--------------------
type 'T ref = Ref<'T>
Full name: Microsoft.FSharp.Core.ref<_>
property LinkedList.First: LinkedListNode<'a>
val not : value:bool -> bool
Full name: Microsoft.FSharp.Core.Operators.not
val findi : f:(int -> 'a -> bool) -> xs:LinkedList<'a> -> int
Full name: Script.LinkedList.findi
val f : (int -> 'a -> bool)
Multiple items
val int : value:'T -> int (requires member op_Explicit)
Full name: Microsoft.FSharp.Core.Operators.int
--------------------
type int = int32
Full name: Microsoft.FSharp.Core.int
--------------------
type int<'Measure> = int
Full name: Microsoft.FSharp.Core.int<_>
val i : int ref
val incr : cell:int ref -> unit
Full name: Microsoft.FSharp.Core.Operators.incr
val nth : n:int -> xs:LinkedList<'a> -> LinkedListNode<'a>
Full name: Script.LinkedList.nth
val n : int
property LinkedList.Count: int
val message : string
val raise : exn:System.Exception -> 'T
Full name: Microsoft.FSharp.Core.Operators.raise
Multiple items
type ArgumentException =
inherit SystemException
new : unit -> ArgumentException + 4 overloads
member GetObjectData : info:SerializationInfo * context:StreamingContext -> unit
member Message : string
member ParamName : string
Full name: System.ArgumentException
--------------------
System.ArgumentException() : unit
System.ArgumentException(message: string) : unit
System.ArgumentException(message: string, innerException: exn) : unit
System.ArgumentException(message: string, paramName: string) : unit
System.ArgumentException(message: string, paramName: string, innerException: exn) : unit
val i : int
More information