fork download
  1. let biApply f (a, b) = (f a, f b)
  2.  
  3. let splitAt n list =
  4. let splitter ((xs, ys), n') c =
  5. if n' < n then
  6. ((c :: xs, ys), n' + 1)
  7. else
  8. ((xs, c :: ys), n' + 1)
  9. List.fold splitter (([], []), 0) list
  10. |> fst
  11. |> biApply List.rev
  12.  
  13. printfn "%A" (splitAt 3 [2; 90; 1; 22])
Success #stdin #stdout 0.22s 12680KB
stdin
Standard input is empty
stdout
([2; 90; 1], [22])