Writing custom generators for ScalaCheck can be one of the more difficult and/or time-consuming parts of using it. As a result I thought I’d start putting together a list of generators that I have written or seen elsewhere. Unfortunately I can’t credit all the ones I’ve seen in other places because I google’d and copied them many moons ago, but I’ll give credit/attribution to all the ones I can.Back to top
This is a combination of generators I wrote, and some that I copied from other places and may have modified a little:
If you struggle to learn new things, check out this podcast interview with Barbara Oakley. A few years ago I read her book, A Mind for Numbers: How to Excel at Math and Science (Even If You Flunked Algebra), and it was helpful to me, and even influenced my book, Functional Programming, Simplified.
The new scala-lang.org docs website looks great. It’s also a reminder to me that I probably didn’t stress enough in the Scala Cookbook that everything in Scala is an object, including numbers. (Hopefully I made it clear that functions are objects.) This Scala REPL example shows some of the methods that are available on Scala integers (
The most important thing I can tell you about selling is to put down this book, and go buy a copy of How I Raised Myself From Failure to Success in Selling, by Frank Bettger. It’s an old book, but it’s the single most important book on “selling” I have ever read.
In addition to that suggestion, here are a few other important sales tips I know.
This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 2.5, “Comparing Floating-Point Numbers in Scala.”
You need to compare two floating-point numbers in Scala, but as in some other programming languages, two floating-point numbers that should be equivalent may not be.
I just learned that MacOS has a softwareupdate command, and further learned that it has a --ignore option, which may or may not let you ignore useless updates. For example, my Mac prompts me daily to update Keynote, Numbers, and Pages, which I rarely (rarely!) use, so I don’t want to bother updating them. I’m hoping the a
softwareupdate command will help me with this.
Alphabet recently authorized another large stock buyback. Like Google’s previous stock repurchase program, the quantity is a little geeky. :)
Scala FAQ: How can I create a range, list, or array of numbers in Scala, such as in a
for loop, or for testing purposes?
to method of the
Int class to create a
Range with the desired elements:
scala> val r = 1 to 10 r: scala.collection.immutable.Range.Inclusive = Range(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
You can also set the step with the
More Pi Day humor. :)
Nothing too earth shattering here today, but if you need an example of the Scala Map class syntax (how to create a Scala Map), or just want to copy and paste a map of month names to numbers (or numbers to names), I hope the following code is helpful: