Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is `List.map` defined?

Tags:

.net-core

f#

I've been looking for the implementation of List.map in F#. The code in list.fs in dotnet/fsharp on GitHub delegates to a mysterious Microsoft.FSharp.Primitives.Basics.List.map function.

Where is the source of that function? I can't find any such directory path in the repo.

like image 284
V0ldek Avatar asked Mar 12 '26 01:03

V0ldek


1 Answers

I think this is it:

    let map mapping x =
        match x with
        | [] -> []
        | [h] -> [mapping h]
        | h :: t ->
            let cons = freshConsNoTail (mapping h)
            mapToFreshConsTail cons mapping t
            cons
like image 55
Brian Berns Avatar answered Mar 14 '26 07:03

Brian Berns



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!