Good material to read on Map in F#












-2















Please help with the following exercise:
enter image description here



what are good source of material can I read to understand how to use Map in F#?



I tried to understand how to use Map.



I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25");;


It works then I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25")
Add("Halloween", "Oct. 31");;


and it gave an error



I had to put a dot after the first Add statement like this:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25").
Add("Halloween", "Oct. 31");;


I'm wondering why is that.



So then that means



let holidays =
Map.empty;;


is how we create a new map. But I want a map of type Map (Team, Points).
So I tried:



let exmaple =
Map.empty.
Add ("Superman", Points 8);;
val exmaple : Map<string,Points> = map [("Superman", Points 8)]


But this is of type map(string, Points) not map(Team, Points).



Also, How do I write "<" after map on stackoverflow so that things follow "<" do appear(that is why i use map() instead of map<>)?



Please help.










share|improve this question




















  • 4





    Have you read the documentation?.

    – Lee
    Jan 3 at 0:42











  • Please help, you know when you start an assignment and you have no idea what is going on? How do I create a variable of type Map<Team,Points>? I tried :Map<Team "Vegeta", Point 5>;;, [("Vegeta", 10)];;, Map<Team, Points> [("Vegeta", 10)];; because I though Map<Team, Points> is a constructor.

    – nafhgood
    Jan 3 at 1:02






  • 1





    BTW, very good material to learn about F#: fsharpforfunandprofit.com

    – AMieres
    Jan 3 at 3:56











  • thanks! Also, do you know how to iterate through elements in a map like a::af for list?

    – nafhgood
    Jan 3 at 14:40
















-2















Please help with the following exercise:
enter image description here



what are good source of material can I read to understand how to use Map in F#?



I tried to understand how to use Map.



I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25");;


It works then I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25")
Add("Halloween", "Oct. 31");;


and it gave an error



I had to put a dot after the first Add statement like this:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25").
Add("Halloween", "Oct. 31");;


I'm wondering why is that.



So then that means



let holidays =
Map.empty;;


is how we create a new map. But I want a map of type Map (Team, Points).
So I tried:



let exmaple =
Map.empty.
Add ("Superman", Points 8);;
val exmaple : Map<string,Points> = map [("Superman", Points 8)]


But this is of type map(string, Points) not map(Team, Points).



Also, How do I write "<" after map on stackoverflow so that things follow "<" do appear(that is why i use map() instead of map<>)?



Please help.










share|improve this question




















  • 4





    Have you read the documentation?.

    – Lee
    Jan 3 at 0:42











  • Please help, you know when you start an assignment and you have no idea what is going on? How do I create a variable of type Map<Team,Points>? I tried :Map<Team "Vegeta", Point 5>;;, [("Vegeta", 10)];;, Map<Team, Points> [("Vegeta", 10)];; because I though Map<Team, Points> is a constructor.

    – nafhgood
    Jan 3 at 1:02






  • 1





    BTW, very good material to learn about F#: fsharpforfunandprofit.com

    – AMieres
    Jan 3 at 3:56











  • thanks! Also, do you know how to iterate through elements in a map like a::af for list?

    – nafhgood
    Jan 3 at 14:40














-2












-2








-2








Please help with the following exercise:
enter image description here



what are good source of material can I read to understand how to use Map in F#?



I tried to understand how to use Map.



I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25");;


It works then I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25")
Add("Halloween", "Oct. 31");;


and it gave an error



I had to put a dot after the first Add statement like this:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25").
Add("Halloween", "Oct. 31");;


I'm wondering why is that.



So then that means



let holidays =
Map.empty;;


is how we create a new map. But I want a map of type Map (Team, Points).
So I tried:



let exmaple =
Map.empty.
Add ("Superman", Points 8);;
val exmaple : Map<string,Points> = map [("Superman", Points 8)]


But this is of type map(string, Points) not map(Team, Points).



Also, How do I write "<" after map on stackoverflow so that things follow "<" do appear(that is why i use map() instead of map<>)?



Please help.










share|improve this question
















Please help with the following exercise:
enter image description here



what are good source of material can I read to understand how to use Map in F#?



I tried to understand how to use Map.



I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25");;


It works then I tried:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25")
Add("Halloween", "Oct. 31");;


and it gave an error



I had to put a dot after the first Add statement like this:



let holidays =
Map.empty.
Add("Christmas", "Dec. 25").
Add("Halloween", "Oct. 31");;


I'm wondering why is that.



So then that means



let holidays =
Map.empty;;


is how we create a new map. But I want a map of type Map (Team, Points).
So I tried:



let exmaple =
Map.empty.
Add ("Superman", Points 8);;
val exmaple : Map<string,Points> = map [("Superman", Points 8)]


But this is of type map(string, Points) not map(Team, Points).



Also, How do I write "<" after map on stackoverflow so that things follow "<" do appear(that is why i use map() instead of map<>)?



Please help.







f#






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 1:19







nafhgood

















asked Jan 3 at 0:21









nafhgoodnafhgood

1619




1619








  • 4





    Have you read the documentation?.

    – Lee
    Jan 3 at 0:42











  • Please help, you know when you start an assignment and you have no idea what is going on? How do I create a variable of type Map<Team,Points>? I tried :Map<Team "Vegeta", Point 5>;;, [("Vegeta", 10)];;, Map<Team, Points> [("Vegeta", 10)];; because I though Map<Team, Points> is a constructor.

    – nafhgood
    Jan 3 at 1:02






  • 1





    BTW, very good material to learn about F#: fsharpforfunandprofit.com

    – AMieres
    Jan 3 at 3:56











  • thanks! Also, do you know how to iterate through elements in a map like a::af for list?

    – nafhgood
    Jan 3 at 14:40














  • 4





    Have you read the documentation?.

    – Lee
    Jan 3 at 0:42











  • Please help, you know when you start an assignment and you have no idea what is going on? How do I create a variable of type Map<Team,Points>? I tried :Map<Team "Vegeta", Point 5>;;, [("Vegeta", 10)];;, Map<Team, Points> [("Vegeta", 10)];; because I though Map<Team, Points> is a constructor.

    – nafhgood
    Jan 3 at 1:02






  • 1





    BTW, very good material to learn about F#: fsharpforfunandprofit.com

    – AMieres
    Jan 3 at 3:56











  • thanks! Also, do you know how to iterate through elements in a map like a::af for list?

    – nafhgood
    Jan 3 at 14:40








4




4





Have you read the documentation?.

– Lee
Jan 3 at 0:42





Have you read the documentation?.

– Lee
Jan 3 at 0:42













Please help, you know when you start an assignment and you have no idea what is going on? How do I create a variable of type Map<Team,Points>? I tried :Map<Team "Vegeta", Point 5>;;, [("Vegeta", 10)];;, Map<Team, Points> [("Vegeta", 10)];; because I though Map<Team, Points> is a constructor.

– nafhgood
Jan 3 at 1:02





Please help, you know when you start an assignment and you have no idea what is going on? How do I create a variable of type Map<Team,Points>? I tried :Map<Team "Vegeta", Point 5>;;, [("Vegeta", 10)];;, Map<Team, Points> [("Vegeta", 10)];; because I though Map<Team, Points> is a constructor.

– nafhgood
Jan 3 at 1:02




1




1





BTW, very good material to learn about F#: fsharpforfunandprofit.com

– AMieres
Jan 3 at 3:56





BTW, very good material to learn about F#: fsharpforfunandprofit.com

– AMieres
Jan 3 at 3:56













thanks! Also, do you know how to iterate through elements in a map like a::af for list?

– nafhgood
Jan 3 at 14:40





thanks! Also, do you know how to iterate through elements in a map like a::af for list?

– nafhgood
Jan 3 at 14:40












1 Answer
1






active

oldest

votes


















4














Three ways of creating an empty Map<Team,Points> are:



let holidays : Map<Team, Points> = Map.empty
let holidays' = Map.empty : Map<Team, Points> // this also works
let holidays'' = Map.empty // even this works if followed by usage


You can add elements with either .Add(t, p) or with Map.add t p:



let twoAdded  = holidays       .Add("Superman", Points 6)       .Add("Batman", Points 5)
let twoAdded' = holidays |> Map.add "Superman" (Points 6) |> Map.add "Batman" (Points 5)


The second way is the functional way.



Your type Team and string are the same because:



type Team = string


is just an alias not a new type.






share|improve this answer


























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014876%2fgood-material-to-read-on-map-in-f%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Three ways of creating an empty Map<Team,Points> are:



    let holidays : Map<Team, Points> = Map.empty
    let holidays' = Map.empty : Map<Team, Points> // this also works
    let holidays'' = Map.empty // even this works if followed by usage


    You can add elements with either .Add(t, p) or with Map.add t p:



    let twoAdded  = holidays       .Add("Superman", Points 6)       .Add("Batman", Points 5)
    let twoAdded' = holidays |> Map.add "Superman" (Points 6) |> Map.add "Batman" (Points 5)


    The second way is the functional way.



    Your type Team and string are the same because:



    type Team = string


    is just an alias not a new type.






    share|improve this answer






























      4














      Three ways of creating an empty Map<Team,Points> are:



      let holidays : Map<Team, Points> = Map.empty
      let holidays' = Map.empty : Map<Team, Points> // this also works
      let holidays'' = Map.empty // even this works if followed by usage


      You can add elements with either .Add(t, p) or with Map.add t p:



      let twoAdded  = holidays       .Add("Superman", Points 6)       .Add("Batman", Points 5)
      let twoAdded' = holidays |> Map.add "Superman" (Points 6) |> Map.add "Batman" (Points 5)


      The second way is the functional way.



      Your type Team and string are the same because:



      type Team = string


      is just an alias not a new type.






      share|improve this answer




























        4












        4








        4







        Three ways of creating an empty Map<Team,Points> are:



        let holidays : Map<Team, Points> = Map.empty
        let holidays' = Map.empty : Map<Team, Points> // this also works
        let holidays'' = Map.empty // even this works if followed by usage


        You can add elements with either .Add(t, p) or with Map.add t p:



        let twoAdded  = holidays       .Add("Superman", Points 6)       .Add("Batman", Points 5)
        let twoAdded' = holidays |> Map.add "Superman" (Points 6) |> Map.add "Batman" (Points 5)


        The second way is the functional way.



        Your type Team and string are the same because:



        type Team = string


        is just an alias not a new type.






        share|improve this answer















        Three ways of creating an empty Map<Team,Points> are:



        let holidays : Map<Team, Points> = Map.empty
        let holidays' = Map.empty : Map<Team, Points> // this also works
        let holidays'' = Map.empty // even this works if followed by usage


        You can add elements with either .Add(t, p) or with Map.add t p:



        let twoAdded  = holidays       .Add("Superman", Points 6)       .Add("Batman", Points 5)
        let twoAdded' = holidays |> Map.add "Superman" (Points 6) |> Map.add "Batman" (Points 5)


        The second way is the functional way.



        Your type Team and string are the same because:



        type Team = string


        is just an alias not a new type.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Jan 3 at 1:39

























        answered Jan 3 at 1:33









        AMieresAMieres

        3,6501611




        3,6501611
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54014876%2fgood-material-to-read-on-map-in-f%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            MongoDB - Not Authorized To Execute Command

            in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith

            Npm cannot find a required file even through it is in the searched directory