Last active
December 25, 2023 07:35
-
-
Save habib-sadullaev/c9841d022c90aef327d7db9e8b1a0a1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Tuple = Tuple with | |
static member inline TupleMap (Tuple, (a, b)) = fun f -> (f a, f b) | |
static member inline TupleMap (Tuple, (a, b, c)) = fun f -> (f a, f b, f c) | |
static member inline TupleMap (Tuple, (a, b, c, d)) = fun f -> (f a, f b, f c, f d) | |
let inline mapTuple f x = | |
let inline map (a: ^a) (b : ^b) = ((^a or ^b) : (static member TupleMap : ^a * ^b -> ^t) (a, b)) | |
map Tuple x f | |
mapTuple (fun x -> x * x + 1) (1, 2) | |
mapTuple string (1, 2, 3) | |
mapTuple id (1, 2, 3, 4) |
Author
habib-sadullaev
commented
Dec 22, 2023
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment