File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
src/FSharp.Control.AsyncSeq Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1344,6 +1344,13 @@ module AsyncSeq =
1344
1344
let! moven = ie.MoveNext()
1345
1345
b := moven }
1346
1346
1347
+ let head ( source : AsyncSeq < 'T >) = async {
1348
+ match ! tryFirst source with
1349
+ | Some x -> return x
1350
+ | None -> return invalidArg ( nameof source) " The input sequence was empty." }
1351
+
1352
+ let tail ( source : AsyncSeq < 'T >) = skip 1 source
1353
+
1347
1354
let toArrayAsync ( source : AsyncSeq < 'T >) : Async < 'T []> = async {
1348
1355
let ra = ( new ResizeArray<_>())
1349
1356
use ie = source.GetEnumerator()
Original file line number Diff line number Diff line change @@ -417,6 +417,13 @@ module AsyncSeq =
417
417
/// then returns the rest of the sequence unmodified.
418
418
val skip : count : int -> source : AsyncSeq < 'T > -> AsyncSeq < 'T >
419
419
420
+ /// Returns the first element of the asynchronous sequence
421
+ val head : source : AsyncSeq < 'T > -> Async < 'T >
422
+
423
+ /// Returns an asynchronous sequence that skips 1 element of the underlying
424
+ /// sequence and then yields the remaining elements of the sequence.
425
+ val tail : source : AsyncSeq < 'T > -> AsyncSeq < 'T >
426
+
420
427
/// Creates an async computation which iterates the AsyncSeq and collects the output into an array.
421
428
val toArrayAsync : source : AsyncSeq < 'T > -> Async < 'T []>
422
429
You can’t perform that action at this time.
0 commit comments