Thinking Functionally with Haskell by Richard Bird
Author:Richard Bird [Bird, Richard]
Language: eng
Format: epub, azw3, pdf
Publisher: Cambridge University Press
Published: 2014-10-31T00:00:00+00:00
The test n==0 forces evaluation of the first argument.
Answer to Exercise C
Take f n x = if x==0 then undefined else 0. Then
foldl f 0 [0,2] = 0
foldl' f 0 [0,2] = undefined
Answer to Exercise D
The answer is: maybe! Although the given version of cp is efficient, it returns the component lists in a different order than any of the definitions in the text. That probably doesn’t matter if we are only interested in the set of results, but it might affect the running time and result of any program that searched cp to find some list satisfying a given property.
According to the fusion rule we have to find a function g so that filter nondec (f xs yss) = g xs (filter nondec yss)
where f xs yss = [x:ys | x <- xs, ys <- yss]. Then we would have
filter nondec . cp
= filter nondec . foldr f [[]]
= foldr g [[]]
Now
nondec (x:ys) = null ys || (x <= head ys && nondec ys)
That leads to
g xs [[]] = [[x] | x <- xs]
g xs yss = [x:ys | x <- xs, ys <- yss, x <= head ys]
Answer to Exercise E
For the first part, we have
T(2k) = 2T(2k−1) +Θ(2k).
By induction we can show The induction step is
Hence T(2k) = Θ(k2k). Now suppose 2k ≤ n < 2k+1, so Θ(k2k) = T(2k) ≤ T(n) ≤ T(2k+1) = Θ((k+1)2k+1) = Θ(k2k).
Hence T(n) = Θ(k2k) = Θ(nlogn).
Answer to Exercise F
Define x <> n = n+1 and n @ x = 1+n. We have (x <> n) @ y = 1+(n+1) = (1+n)+1 = x <> (n @ y)
The second proof is similar.
Answer to Exercise G
The induction step is
(foldr f a (x:xs),foldr g b (x:xs)
= (f x (foldr f a xs),g x (foldr g b xs))
= h x (foldr f a xs,foldr g b xs)
= h x (foldr h (a,b) xs
= foldr h (a,b) (x:xs)
Download
Thinking Functionally with Haskell by Richard Bird.azw3
Thinking Functionally with Haskell by Richard Bird.pdf
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12568)
Hello! Python by Anthony Briggs(9912)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9795)
The Mikado Method by Ola Ellnestam Daniel Brolund(9777)
Dependency Injection in .NET by Mark Seemann(9337)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8295)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7762)
Grails in Action by Glen Smith Peter Ledbrook(7696)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7049)
Microservices with Go by Alexander Shuiskov(6816)
Practical Design Patterns for Java Developers by Miroslav Wengner(6728)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6673)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Angular Projects - Third Edition by Aristeidis Bampakos(6078)
The Art of Crafting User Stories by The Art of Crafting User Stories(5606)
NetSuite for Consultants - Second Edition by Peter Ries(5544)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5346)
Kotlin in Action by Dmitry Jemerov(5062)
