I have a struct constructor that takes a tuple, but I need to construct it with two arrays. My current solution is running into a problem while trying to map the function. The currying goes away. Hopefully there is an alternative way of doing this.
type Example =
struct
val X : int
val Y : int
new(x: int, y: int) = { X = x; Y = y} // constructor is (int * int -> Example)
end
let foo = fun x y -> Example(x, y) // to curry; foo is now (int -> int -> Example)
let bar = Array.map foo // oh no; it changed to (int array-> (int -> Example) array)
// how can it be (int array -> int array -> Example array) instead?
// this is my imagined implementation
let a = seq{0 .. 100} // these sequences are filler for this demonstration
let b = seq{0 .. 100}
let myArray = bar a b // where myArray is (Example array)
I found it. The solution to this is
map2.Swapping
let bar = Array.map footolet bar = Array.map2 fooallows the use oflet myArray = bar a bwherebarisint array -> int array -> Example array