> For the complete documentation index, see [llms.txt](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://demystifyfp.gitbook.io/fstoolkit-errorhandling/fstoolkit.errorhandling/result/arrays/partitionresults.md).

# partitionResults

Namespace: `FsToolkit.ErrorHandling`

## Function Signature

```fsharp
Result<'ok, 'error>[] -> 'ok[] * 'error[]
```

Separates an array of `Result` values into a tuple of the `Ok` values and the `Error` values, preserving order within each group.

## Examples

### Example 1

```fsharp
let results = [| Ok 1; Error "bad"; Ok 2; Ok 3; Error "worse" |]

results |> Array.partitionResults
// ([| 1; 2; 3 |], [| "bad"; "worse" |])
```

### Example 2

```fsharp
// string -> Result<int, string>
let tryParseInt str =
  match System.Int32.TryParse str with
  | true, x -> Ok x
  | false, _ -> Error (sprintf "unable to parse '%s' to integer" str)

[| "1"; "foo"; "3"; "bar" |]
|> Array.map tryParseInt
|> Array.partitionResults
// ([| 1; 3 |], [| "unable to parse 'foo' to integer"; "unable to parse 'bar' to integer" |])
```

### Example 3

All Ok values:

```fsharp
[| Ok 1; Ok 2; Ok 3 |] |> Array.partitionResults
// ([| 1; 2; 3 |], [||])
```

All Error values:

```fsharp
[| Error "a"; Error "b" |] |> Array.partitionResults
// ([||], [| "a"; "b" |])
```
