Following the release of Dyalog APL for the Raspberry Pi came a hectic week with no time to play… But now the next sensor has arrived, so it is time to power the robot back up. In the video below, we practice turning it through 180 degrees using APL.
The big day will be the day after tomorrow, when the three mice (who were once blind) are bringing a bag of robot parts and coming to play with us. Jason and I will help them solder things together and get APL code up and running. We’ll work on getting our own sonar operational – and Jasons LCD display, if we can figure it out.
My dad is originally from the Cape, and I grew up in Botswana, so hopefully I can be forgiven for feeling that it is very cool to find Dyalog APL at the core of a project which aims to increase financial literacy and support the financial stability of small and medium-sized enterprises in South Africa, by delivering a “cash flow optimizer” on phones and tablets:
In response to an earlier post on driving an 8-bar LED using the Raspberry Pi, Roger Hui commented that 8 lights should be sufficient to display the output of a 1-d Game of Life. The code snippets displayed in this post are based on some working code that Roger was also kind enough to forward to me.
The following two functions provide the basic building blocks for the computation of the next generation of a 1-d cellular automaton:
bits←{(8⍴2)⊤⍵} ⍝ Encode a number as 8 binary bits
neighbors←{↑¯1 0 1∘.⌽⊂⍵} ⍝ Map vector => 3-row matrix with neighbors
These allow us to perform the following transformations:
With these, it is now easy to define a function to compute the next generation of a pattern for a given Wolfram Code (and test it with a couple of arguments):
We subtract the result of the base-2 decode from 8, because the least significant bit (bit 0) is the 8th element of the vector returned by the bits function. Next, we define an operator which returns a matrix containing a number of generations:
Finally, we can add 1 to the boolean matrix and use it to index into a 2-element character vector, to get better “visualization” of the result (10 generations of Wolfram code 20):
The function also works with longer inputs – in the example below a random input of length 60 (20 generations of Wolfram code 18, this time using just blank and asterisk for the display):
Finally, we can light the lights using the BarLED class from our GitHUB repository – and the Quick2Wire interface board and LED Bar – see the original post for an explanation. The video below shows the output resulting from the following APL expressions
Many thanks to Roger for the inspiration to take this one step further (and the code)! For a 2-dimensional implementation of Conway’s classic Game of Life, see the video by John Scholes at http://www.youtube.com/watch?v=a9xAKttWgP4.
And now, as they say, for something completely different. Our robot is running Dyalog APL version 13.2 for the Raspberry Pi, which was released on our major platforms (Windows, Linux, AIX) in January 2013. The next release of Dyalog APL will be version 14.0, which currently has a tentative delivery date of “sometime in the 1st half of 2014”.
We are in the final stages of the design of a number of new language features, and would like to invite interested parties to install and test the “v14.0 Tech Preview” – or download and review the Release Notes. Some of the features may be controversial, so we welcome your feedback – whether you are a user of Dyalog APL or not. The key features that we hope to validate through the release of the preview include:
New primitive operator rank (identical to the SHARP APL implementation and the ISO/IEC 13751 Extended APL Standard)
New primitive operator key (similar to the J definition)
New primitive function tally (identical to the J definition)
Function trains (similar to trains of length 3 in J)
An extension to dyadic index of (iota), to work on higher-rank arrays (for example, to search for rows of a matrix)
An extension to mix with axis, providing greater compatibility with IBM APL2
New user commands to control boxed / truncated session output
Experimental changes to the binding of function definitions
A number of these new features were discussed by John Scholes and Roger Hui at the Dyalog’12 conference – the video can be viewed on the Dyalog Conference YouTube feed, and is also embedded below (but beware, some of the design details have changed since this recording was made):
“Tech Preview II”
The current invitation is in fact for the second release of the preview; the first release was distributed to a small number of well-known (and loved) troublemakers, and has already resulted in one important change to the definition of the proposed Key operator. I would like to thank Phil Last and Paul Mansour for feedback which has resulted in the operand function being passed the relevant key value as a left argument on each invocation.
Note to users of the first preview version: The default “loco” (1060 I-Beam) setting is 2 (trains, “late” binding) in this release, as this is the setting that we are most keen to have applications tested with. It was 0 (no trains, traditional binding) in the first preview.
How You Can Help
If you are able to commit to setting some time aside to test the new language features and providing us with feedback, please write to sales at dyalog dot com and let us know why YOU should be included in the evaluation team. It would be particularly valuable to us if you have time to run an existing application on v14.0; one of the proposed language extensions is a change to name binding, which will impact the behaviour of certain language constructs. Although most of these would be labelled “exotic”, there is a chance that they are used in existing applications, and we are very interested in learning about the degree to which these changes actually cause problems for existing applications. If serious “adverse reactions” are experienced, we may be forced to abandon some of the new features.
If you do not have time to install and test the preview, you are welcome to read the Release Notes and write to us with feedback, either in response to this blog post or by writing to language at dyalog dot com.
Thanks in advance to everyone who is able to participate!
Although the news had not yet appeared on the Dyalog webpage when this was written, the CTO blog has access to exclusive sources and is therefore able to present this scoop: The big day has finally come – Dyalog APL version 13.2 is now available to anyone with a Raspberry Pi, and can be downloaded immediately from http://packages.dyalog.com! We will of course be making official announcements via various channels over the next few days, so keep an eye on our web page – but remember that you saw it here first!
In the above clip, you can see that the Dyalog C3Pi got a little over-excited: while celebrating (and testing) the new release with an autonomous drive on my kitchen floor (in the middle of dinner preparations), the robot got a bit too close to an obstacle and dragged the on/off switch along a pillow, switching itself off in the process! A single infra-red sensor doesn’t give much information for autonomous driving, but we have placed orders for a high-definition sonar, which should arrive next week. Stay tuned for further developments!
A Full Implementation of Dyalog APL
Note that, although the Pi version of Dyalog APL is free for educational and non-commercial use, is not technically restricted in any way – it has exactly the same features as any other 32-bit Linux-based (Unicode) version of Dyalog APL.
You are also welcome to take a look at the User Guide before installing the software – it also contains useful links to other resources that you can use to learn about Dyalog APL. If you would like to take a look at APL but do not (yet) have Raspberry Pi, educational and non-commercial licenses are also available for Linux/x86 and Windows – and you can also try APL online at http://tryapl.org (apologies in advance if you have a tablet, good support for tablets is coming soon to TryAPL).