Tags
This post contains some simple code for calculating the square root of 2 and then generating the bits of the value.
It’s a companion to a post on my other blog.
15 Friday May 2020
Posted in Fun
Tags
This post contains some simple code for calculating the square root of 2 and then generating the bits of the value.
It’s a companion to a post on my other blog.
07 Thursday May 2020
Last time I showed you the functions necessary for Life — for John Conway’s game of Life, that is. We ended up with a set of functions you can use to generate frames of a Life session.
This time I’ll show you an object-oriented version (a Life class) along with some other tweaks to make things look nicer.
03 Sunday May 2020
You may have heard that mathematician John Conway died last April. To his everlasting dismay, most people only know him for his “game” of Life (which he considered trivial and inferior to his real mathematical work). Unfortunately for Conway, his Life game is fascinating.
To honor his passing, I whipped up a Python version that I thought I’d share. Python is about the only language I’ve used a lot in which I’ve never implemented Life, so high time I did, right?
25 Saturday Apr 2020
Posted in Python
Tags
Aspect-Oriented Programming, computer language, programming language, Python 101, Python code, Python decorator
Last time I began exploring Python decorators, which are a way of having one function “wrap” another function. Because the wrapper has access to both the input parameters and the return value, it can modify these values (unbeknownst to the inner function).
This time I pick up where I left off by exploring decorators modifying return values, decorators that take parameters, and decorators in classes.
24 Friday Apr 2020
Posted in Python
I’ve been playing around with what Python calls decorators. They’re a built-in way of implementing Aspect-Oriented Programming techniques in Python. In fact, they’re quite powerful.
Since they aren’t a common language feature, they can be a little confusing at first, so I thought I’d try my hand at laying out how they work.
22 Wednesday Apr 2020
Posted in CS101
Tags
computer code, computer programming, function currying, Python code, software design, software development
I saw a video recently about function currying, and it triggered the realization that currying might solve a problem I’ve been pondering in the context of language parsing. The problem involves knowing how many arguments an operator expects, what’s called the arity of an operation or function. It can vary from zero to many.
It occurred to me that, with currying, there could be a language where operations always take just one argument. That would solve a challenge for a mathematical expression language I have in mind.
27 Sunday Oct 2019
Earlier this month, on my other blog, I wrote about the Playfair Cipher, a polygraphic substitution cipher invented by Sir Charles Wheatstone in 1854.
At the time I mused about writing some Python to automate using the cipher, and now I’ve done that, so here it is:
23 Sunday Jun 2019
Tags
There’s a fairly simple puzzle, called The Eight Queens, that I’ve long favored as a project for first semester CS students. The problem is simple enough for a beginner to tackle, yet also interesting enough to be engaging. (And just tricky enough to be a nice beginner challenge.)
Due to a discussion on my other blog, I dug out an old Python implementation I had, and, after looking at it, I thought it might be worth writing a post about. If nothing else, as I said, the problem is interesting enough to be engaging.
14 Tuesday May 2019
Posted in CS101
I’m returning to the full-adder logic circuit modeling to present the code for a version that tries to capture the timing of the signals.
The goal is to take a closer look at the intermediate states of the adder as signals trickle through it.
10 Friday May 2019
Posted in Fun
Lately I’ve been exploring the idea of a vector space with a large number of dimensions (but few degrees of freedom). A model was presented with five degrees of freedom in 500 dimensions (neurons, as it happens).
The question is, given the axes are bit-level, does normal vector manipulation semantics make sense. My contention is it has severe problems.