Posts

Showing posts with the label #APL

A concise solution to a fiddly coding problem

Image
I My pomodoro timer is coming on nicely. I'll post about progress in the next day or so. For now, here is a short story about a problem I hit while working on the project, and the happy solution that I came up with. For some time I've kept an online journal for each project I'm working on. Like some blogs, the journals used to have the latest entries at the top. Here's a sample journal file: # Project journal for zero-web ## Thursday 07 February 2019 I added 2 new pages. ## Monday 04 February 2019 I've created a homepage. I'll serve it with websocketd. I found that order confusing. I decided that I'd prefer the posts ordered as they would be in a paper diary, with the latest posts last. That way I could read the  project history like a book. The problem: I have a lot of project journals, and I really didn't want to edit them all by hand. I decided to write a program to do it. The problem was simple to solve using APL. Regul...

Raspberry Pi and BBC micro:bit for C2Pi

Image
Right now the Raspberry Pi and the BBC micro:bit look like a winning team. If you're f ollowing this blog you will know that I am evaluating new hardware and software for C2Pi (the re-generated C3Pi, neé Trackbot). Over the weekend I discovered that the micro:bit now supports MicroPython. Since I am looking for a micro that supports a language with a REPL, I had to investigate. MicroPython on the pyboard I've been a fan of MicroPython for a while. It runs on several platforms, including a custom board (the pyboard). I first met the pyboard, and Damien George, (its designer, and the original implementer of MicroPython) at an Open Technology conference in Cambridge a couple of years ago. I learned that MicroPython is a full, optimised implementation of Python 3; the only difference lies in MicroPython's specialised libraries, which  focus on direct access to the hardware. At the time I felt that the pyboard and MicroPython had great potential but I couldn...

C3Pi regenerates!

Image
My old friend C3Pi, like Doctor Who, regenerates from time to time. He started life as Trackbot - a tracked robot, powered by an Arduino Nano, with fairly limited capabilities. Some years later he acquired a Raspberry Pi, and replaced the Nano by a Teensy 3.1. C3Pi has proved a good subject for experiments, as did the Dyabots - the mobile robots built by Dyalog to experiment with APL as a control language for robotics. But... The C3Pi and Dyabot designs had their limitations, and it's time to apply the lessons learned. Issues with C3Pi and Dyabot Several factors have stopped me achieving all I want to with the old version of C3Pi. I found it awkward to recharge or replace C3Pi's batteries. C3Pi’s limited room made it hard to add new capabilities. The Pi was a veteran model 2 B+; C3Pi would benefit from the processing power of the Pi 3. I found the Teensy disconnect-compile-upload-reconnect-test cycle frustratingly slow . The motor control...

Three easy ways to avoid off-by-one errors in your software

Image
Here's how to avoid one of the commonest software bugs If you're in the software business you've probably encountered the dreaded 'off-by-one' error. An off-by-one error often occurs when an iterative loop iterates one time too many or too few. Someone might use "is less than or equal to" where "is less than" should have been used. It's also easy to forget that a sequence starts at zero rather than one. To put it another way, we sometimes fail to distinguish between a count (how many are there?) and an offset (how far is that from here?) Ten gaps in eleven posts These problems aren't unique to programming. At the time of the last millennium, there was a lot of discussion as to whether it should have been celebrated on 1st January 2000 or 2001. In debates about the millennium off-by-one errors may not be too serious. In software they can be fatal. How can you avoid them? Here are three techniques which help. I'll ...

A new/old approach to Parallel processing

Image
Morten Kromberg of Dyalog APL has just published a video of his keynote from the PLDI 2016 ARRAY Workshop. It's titled Notation for Parallel Thoughts and it describes some exciting innovations in the field of programming for parallel processing.

Neural networks on the Raspberry Pi: Sigmoid, tanh and RL neurons

Image
A brief introduction to ANNs - part 3 In the previous post about ANNs we looked at the linear neuron and the perceptron. Perceptrons have been used in neural networks for decades, but they are not the only type of neuron in use today. When they were first invented, they seemed capable of learning almost anything. However, in 1969, Minsky and Papert published their book 'Perceptrons' which showed that a single perceptron could never be trained to perform the XOR function. You'll see in the next post why this is so (and why it's not a huge problem), but for now, let's look at three other common neuron models. Like the linear neuron and perceptron, these start by calculating the weighted sum of their inputs. Recall that you can implement the linear neuron like this:       ln←{⍺+.×⍵} sigmoid neuron calculates the same weighted sum of inputs, but then it applies the sigmoid function to the result. The sigmoid function is defined in wikip...

Big data on a small computer!

Image
Neural Networks on the Raspberry Pi I've been having some fun experimenting with ANNs ( Artificial Neural Networks ) on the Raspberry Pi . I've been interested in ANN research for a very long while: I wrote my first simulator back in 1974. I developed that first version in ALGOL60. I've recently re-written and extended it in Dyalog APL , and now it runs on the Raspberry Pi. Why APL? I've found APL a great choice for ANN research and education, for several reasons: It's easy to learn, and fun! It's concise and easy to test. It handles arrays naturally. It has a rich set of primitives for data manipulation and calculation. It supports a pure functional programming style. Dyalog APL has great support for parallel computing. The Raspberry Pi version is free for non-commercial use. Inexpensive ANN computing I'm using a Raspberry Pi B model 3, but it runs acceptably fast on earlier versions of the Pi. I haven't yet tried it on the Pi ...