@@ -23,28 +23,6 @@ module Array =
2323 ( first, middle, Some last)
2424
2525module Seq =
26- /// Groups consecutive elements by a classifier function, preserving order.
27- /// Returns a list of (key * items list) tuples where items with the same consecutive key are grouped together.
28- /// Example: [ 1;1;2;1] with classifier (fun x -> x) produces [ (1, [ 1;1] ); (2, [ 2] ); (1, [ 1] )]
29- let groupConsecutiveBy ( classifier : 'T -> 'Key ) ( source : 'T seq ) : ( 'Key * 'T list ) list =
30- let folder ( groups , currentKey , currentGroup ) item =
31- let key = classifier item
32- match currentKey with
33- | None -> ( groups, Some key, [ item])
34- | Some prevKey when key = prevKey -> ( groups, currentKey, item :: currentGroup)
35- | Some prevKey -> (( prevKey, List.rev currentGroup) :: groups, Some key, [ item])
36-
37- let ( groups , finalKey , finalGroup ) =
38- source |> Seq.fold folder ([], None, [])
39-
40- match finalKey with
41- | None -> []
42- | Some key -> ( key, List.rev finalGroup) :: groups
43- |> List.rev
44-
45- let inline tryMin xs =
46- if Seq.isEmpty xs then None else Some ( Seq.min xs)
47-
4826 // https://github.com/dotnet/fsharp/blob/b9942004e8ba19bf73862b69b2d71151a98975ba/src/FSharp.Core/seqcore.fs#L172-L174
4927 let inline private checkNonNull argName arg =
5028 if isNull arg then
@@ -70,25 +48,3 @@ module internal Type =
7048 |> Seq.tryFind ( fun attr -> attr :? 'T)
7149 |> Option.map ( fun attr -> attr :?> 'T))
7250 |> Seq.toList
73-
74- [<AutoOpen>]
75- module StringBuilder =
76- open System.Text
77-
78- type StringBuilder with
79- /// Appends each string in the sequence with indentation
80- member this.AppendIndentedLine ( indent : string , lines : #seq<string> ) =
81- lines |> Seq.iter ( fun line -> this.Append( indent) .AppendLine( line) |> ignore)
82- this
83-
84- /// Splits text into lines and appends each with indentation
85- member this.AppendIndentedLine ( indent : string , text : string ) =
86- let lines = text.Split([| '\n' ; '\r' |], StringSplitOptions.None)
87- this.AppendIndentedLine( indent, lines)
88-
89- member this.AppendLines ( lines : #seq<string> ) =
90- this.AppendJoin( Environment.NewLine, lines)
91-
92- /// Returns the string content with trailing whitespace removed
93- member this.ToStringTrimmed () =
94- this.ToString() .TrimEnd()
0 commit comments