Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Given the definition in Haskell:
fmap :: (a -> b) -> [a] -> [b]
fmap g xs = reverse (map g xs)
With Functor law:
(fmap g . fmap h) xs = fmap (g . h) xs
Using list xs :: [Int], prove the definition does not satisfy the law:
Expert Solution
arrow_forward
Step 1
A functor is a function that takes a function, fmap (say) that returns another function. fmap() is also known as function map
Let's see the functor instance for a list with id.
fmap id (x: xs)
= (id x) : fmap xs
= x : fmap xs
As per the question, fmap id (x: xs) = (x: xs) which satisfies the first law, we can conclude that
= (fmap g).(fmap h) (x : xs)
= fmap g (fmap h (x: xs))
= fmap g ((h x) = fmap h xs)
= (g.h x) = fmap g(fmap h xs) which doesn't satisfies the law.
Step by stepSolved in 2 steps
Knowledge Booster
Similar questions
- Use the STL stack template class to develop a custom queue class (named cnPtrQueue). ○ The cnPtrQueue has member variable numItems (that keeps track of the number of items in the queue), which should be helpful for implementing the member function size() (for inspecting the number of items in the queue). ● Use the cnPtrQueue to perform a breadth-first (level) traversal of a linked list of linked lists data structure and process (print) the data items stored in the structure. Fill in the "holes" intentionally left: ► Function body of ShowAll_BF in nodes_LLoLL.cpp. ○ You are to put the cnPtrQueue (NOT the STL queue) to use here.arrow_forwardImplement the Linked List using head and tail pointer. Interface (.h file) of LinkedList class is given below. Your task is to provide implementation (.cpp file) for LinkedList class. Interface: template<class Type> class LinkedList { private: Node<Type>* head; Node<Type>* tail; <Type> data; public: LinkedList<Type>(); LinkedList<Type>(const LinkedList<Type> &obj); void sortedInsert(Type); Type deleteFromPosition(int position); //deletes the node at the particular position Type delete(int start,int end); //deletes the nodes from starting to ending position bool isEmpty()const; void print()const; ~LinkedList(); }; program in c++.arrow_forwardDefine collapse which reduces a list of MkType a b to two lists of type a and b respectively. You should respect the orignal ordering of the list . collapse::MkType a b -> ([a],[b]) collapse = undefined answer in haskell form.arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY