PurelyFunctional.tv Newsletter 336: My book: next week?
Book status 📖
Word from Manning is that the book will be available in early access next week. It's not for sure, but I'm crossing my fingers. 🤞
As you may know, I'm writing a book called Taming Complex Software, which is an introduction to functional programming. It has been a long journey and lots of work, but I've turned in the first three chapters for Manning's Early Access Program.
But I can tell you something that you'll only hear in this newsletter: there are already 6 chapters done, and 2 more super close to done. Those chapters 4, 5, and 6 are being reviewed right now. They'll be released as part of the program when ready.
Brain skill 😎
read lots of opinions
We are early in the invention of software. We don't really know what we are doing. You're better off reading lots of opinions, especially those you don't agree with, and certainly ones you are not familiar with. Variety is the name of the game.
Currently recording 🎥
Recently, I started a course called Property-Based Testing with test.check. Property-based testing (PBT) is a powerful tool for generating tests instead of writing them. You'll love the way PBT makes you think about your system. And you can buy it now.
Here's the new lesson for this week:
- A tour of the built-in generators , in which we look at the basic generators that are built-into test.check.
I've made the first and fifth lessons free to watch. Go check them out.
Members already have access to the lessons. The Early Access Program is open. If you buy now, you will get the already published material and everything else that comes out at a serious discount. There is already 127 minutes of video, and looking at my plan, this o ne might be 6-7 hours. But that's just an estimate. It could be more or less. The uncertainty about it is why there's such a discount for the Early Access Program.
Clojure Challenge 🤔
Last week's challenge
The puzzle in Issue 335 was to write an implementation of merge sort.
You can check the submissions out here. There are some great implementations by Steve Miner, Ilya Bernshteyn, Jos van Bakel, and Mark Champine.
This week's challenge
property-based tests of quartiles
Now that we have implementations of quartiles, how do we know it works? What properties would you want the quartiles values to obey?
Here are a few properties to implement:
- The median (q2) should be between the first and last numbers.
- q0 <= q1 <= q2 <= q3 <= q4
These are invariants that we can guarantee. But invariants are just one way to create properties. We can also do a metamorphic test:
- Generate a random list l1.
- Calculate the quartiles l1q.
- Add a number to the list l1 that is greater than the max, call it l2.
- Calculate the quartiles l2q.
The values in l2q should be greater than or equal to the corresponding values in l1q.
Implement these three properties. That's the challenge this week.
As usual, please send me your answers. I'll share them all in next week's issue. If you send me one, but you don't want me to share it publicly, please let me know.