CSBiology / FSharpAux

Auxiliary functions and data structures for the F# programming language
MIT License
23 stars 16 forks source link

`map4` #27

Open omaus opened 1 year ago

omaus commented 1 year ago

Description

It is tedious to work with 4 enumerable collections (i.e., seqs, arrays, lists) at once without proper functions. FSharp.Core.Collections already provides mapping functions for one, two, or three collections, yet a mapping function for four is missing.

kMutagene commented 1 year ago

ChatGPT has these insights for you:

It is tedious to work with 4 enumerable collections (i.e., seqs, arrays, lists) at once without proper functions. FSharp.Core.Collections already provides mapping functions for one, two, or three collections, yet a mapping function for four is missing.

It is even more tedious to work with 5 enumerable collections at once without proper functions. FSharp.Core.Collections provides mapping functions for one, two, three, and four collections, yet a mapping function for five is still missing.

Working with 6 enumerable collections simultaneously without proper functions is a nightmare. Even FSharp.Core.Collections' mapping functions for one through five collections aren't enough to make this task any easier.

Attempting to work with 7 enumerable collections without a proper function is like trying to juggle seven flaming swords. It's just not feasible. We need a mapping function for seven collections, stat!

Working with 8 enumerable collections at once is like trying to solve a Rubik's Cube blindfolded. It's not impossible, but it's certainly not easy. We need a mapping function for eight collections to make this task less daunting.

If you thought working with 8 collections was tough, just wait until you try working with 9! FSharp.Core.Collections' mapping functions for one through eight collections just aren't cutting it. We need a mapping function for nine collections, and we need it now!

kMutagene commented 1 year ago

It even created the code for you, but seems like it ran out of patience for the last one:

// Working with 4 enumerable collections at once without proper functions is tedious.
// FSharp.Core.Collections provides mapping functions for one, two, and three collections, yet a mapping function for four is missing.
let map4 f (a1: _[]) (a2: _[]) (a3: _[]) (a4: _[]) =
    Array.init (Array.length a1) (fun i -> f a1.[i] a2.[i] a3.[i] a4.[i])

// Working with 5 enumerable collections simultaneously without proper functions is a nightmare.
// FSharp.Core.Collections' mapping functions for one through four collections aren't enough to make this task any easier.
let map5 f (a1: _[]) (a2: _[]) (a3: _[]) (a4: _[]) (a5: _[]) =
    Array.init (Array.length a1) (fun i -> f a1.[i] a2.[i] a3.[i] a4.[i] a5.[i])

// Attempting to work with 6 enumerable collections without a proper function is like trying to juggle six flaming swords.
// We need a mapping function for six collections, and we need it yesterday!
let map6 f (a1: _[]) (a2: _[]) (a3: _[]) (a4: _[]) (a5: _[]) (a6: _[]) =
    Array.init (Array.length a1) (fun i -> f a1.[i] a2.[i] a3.[i] a4.[i] a5.[i] a6.[i])

// Working with 7 enumerable collections at once is like trying to solve a Rubik's Cube blindfolded.
// We need a mapping function for seven collections, and we need it now!
let map7 f (a1: _[]) (a2: _[]) (a3: _[]) (a4: _[]) (a5: _[]) (a6: _[]) (a7: _[]) =
    Array.init (Array.length a1) (fun i -> f a1.[i] a2.[i] a3.[i] a4.[i] a5.[i] a6.[i] a7.[i])

// Working with 8 enumerable collections at once is like trying to herd eight cats.
// FSharp.Core.Collections' mapping functions for one through seven collections are no match for this task.
// We need a mapping function for eight collections, and we need it fast!
let map8 f (a1: _[]) (a2: _[]) (a3: _[]) (a4: _[]) (a5: _[]) (a6: _[]) (a7: _[]) (a8: _[]) =
    Array.init (Array.length a1) (fun i -> f a1.[i] a2.[i] a3.[i] a4.[i] a5.[i] a6.[i] a7.[i] a8.[i])

// Working with 9 enumerable collections at once is like trying to perform brain surgery while skydiving.
// FSharp.Core.Collections' mapping functions for one through eight collections are simply not enough to make this task manageable.
// We need a mapping function for nine collections, and we need it yesterday!
let map9 f (a1: _[]) (a2: _[]) (a3: _[]) (a4: _[]) (a5: _[])