What means the code below?
singleton 1 'a' == fromList [(1, 'a')]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
singletonandfromListappear in several container modules.Typically,
singletonreturns a container with a single element, andfromListreturns a container with all of the elements from the list (modulo key duplication in mappings).The example you give shows
singletontaking 2 arguments, which implies that the container is a mapping (Set,IntSet,HashMap, etc…), and expects the key and value of the single element. For mappings,fromListexpects a list of key, value pairs.The equality you show states that the container with a single element that maps the number
1to the character'a'is the same whether it is constructed usingsingleton, orfromListwith a single-element list.