This blog post is going to be about the c++ keyword mutable, it is also going to go into using mutable for data caching. To motivate this I am going to give an example from python. If I have a class with a property which is expensive to compute I want to cache it and only recalculate it when necessary. Continue reading ‘Mutable and Data Caching’

## Archive for the 'CodeProject' Category

### Mutable and Data Caching

### FizzBuzz

FizzBuzz is variously; a drinking game, a maths game, a way of learning numbers in a foreign language and more importantly (for this blog) a programming kata. The principle of FizzBuzz is a counting and substitution game you count to a limit and replace some numbers with words. In the classic example you replace any number which is divisible by 3 with Fizz and any number divisible by 5 with Buzz, and any number which is divisible by both with FizzBuzz. Continue reading ‘FizzBuzz’

As it is easy to get started I first wrote a prime finding algorithm in Python. I used a very basic algorithm for this. I store a list of prime numbers, and I check the numbers less than the square root of the possible prime, if any are a factor of the number I’m checking then it’s a composite otherwise I append it to the list of prime numbers.

The code for this is on my Box account here. Continue reading ‘Finding Primes: Part II – A Python Implementation’

This is the second part of my article about auto generating a C++ class using Perl. Download the full script. Continue reading ‘Auto-generate C++ Classes Using Perl, Part II’

This is the first part of a post about a short utility I have written in Perl. I use it to generate C++ header and source files with method stubs depending on the arguments given. In this post I will be explaining some more general Perl techniques I use that aren’t specific to this file. Continue reading ‘Auto-generate C++ Classes Using Perl, Part I’