A Demo of ‘Extended’ Labs

In this post I am going to show a video of what can be done with the addition of media to labs (and that media includes parallel interfaces), but before that an overview of how these features are being put into place.


To begin, text files with .ijt extensions are recognized as lab files. The have a two part structure with the first part up to the single right parenthesis being the ‘lecture’, followed by text executed as if it were part of the operating environment. The results of this evaluation and the instructions are shown to the learner with one exception – the text preceded and followed by the PREPARE keyword is executed but neither they nor the results they produce are shown. This allows side effects such as having files loaded and run to adjust the environment and showcase specific concepts to be taught.


In the case of the example lab, ‘J conference 2014 – Toronto’, the PREPARE section launches the frame1 display which shows the jhs environment and an interactive display of shape and type side by side. frame1 is patterned on the demo9 example in the studio menu of the JHS environment, creating an html file with frames to display the different components.  The result is  two interactive frames side by side, with the jijx window displaying the ‘lecture’ for this particular lesson, in this case hints of phrases to enter.


The second lesson launches frame2 but in that case a video replaces the shape and type demo. This video is the Ratio Arithmetic promo video that I produced and originates from my account in youtube. At this point only external videos may be run by the Safari browser. By using video animations and explanations of more complicated concepts combine to make for easier learning . At least that is the potential use, whether the combination of video, text and interaction works to make things clearer is down to the skills of the creator.


BlogLab3The final lesson returns back to the interactive jhs environment.

This will probably be as far as I will take this experiment with the lab framework, as Eric Iverson has suggested that it may be better to use the sp framework which has more capability for the new forms of interaction. The key thing I believe is to retain the structure of the lab files so that they are backward compatible and more importantly to potentially create a tool to allow easier creation of the augmented labs and at the same time enforcing lab structure with consistent results across platforms.

A short video to promote the J language

In response to work being done on the J forums in promoting J to various audiences, I decided to take aim at what I think would be a good audience for learning J – middle and high school math students. I kept the video short and focussed on the the utility of J’s use of ratio arithmetic.

If it looks as if this is on the right track, I have ideas on a few more of this style of video to raise the interest of newcomers to the J programming language.

Using CSS and HTML to display the shapes of arrays on the JHS platform

The following video will provide an idea of how HTML and CSS can be used to more clearly show the shapes of arrays on the JHS platform. This includes arrays with zero valued dimensions and arrays with single valued dimensions that would be displayed ambiguously in the text based format.

If you have not already viewed the preceding blog post on displaying different types of J variable, it may be worthwhile to take a look at it here. There is a brief review of types in this shape video but it does not cover the information in any great detail.

Using HTML and CSS to view Types in the JHS platform of J

Time flies when you are having fun, or maybe just time flies as I look back to how long it is since I have posted here. In any case I am back and ready to explore some new developments in the way that I am using the JHS platform of J.

One of the things that has frustrated me with J is that at times I spend a lot of time trying to figure out problems based on simple (and incorrect) assumptions I have about the information that I am being shown. J has an elegantly minimalistic way of showing the results of operations in its interactive environment. Unfortunately, it does not always distinguish between certain key qualities when it displays its results. It becomes my job as a programmer to confirm what I am seeing as what is really being presented and this is especially true for type information. With modern web browsers it has become possible to provide this additional information as part of the results and this is explored in the following video.

Since there was not enough time to go into all the details the screens below provide some of the background to the css and elements of html that are created in order to provide the new html based display. I provide this information for all to use and only ask that if you use it that in your best judgement you use it in a mindfully positive way.


I hope to follow up in a week with the HTML and CSS approaches I have explored to display differently shaped arrays unambiguously, but last time I said that resulted in almost two years between posts. 🙂

Augmented View of Arrays (Redux)


After looking back at the previous post I did notice one mistake. The shape for the following diagram should have been 1 2 3 instead of 2 3. If the shape had been 2 3 then the diagram would have had a plane rather than a cube as the ‘shape structure’.

 1 2 3 $ 0

Augmenting Frank’s Dual-View Representation by Simplifying:

After several weeks of reflection, I realized that the previous solution to visualizing Frank’s Dual-View could be made simpler  by displaying the absence of edges when there are zero valued dimensions in the shape. The following post will compare the two options with a following critique of the differences.

Case 0 – Empty shape for scalar value – Shape ’empty’


Old version

New version

Critique: The only difference here is colour to distinguish the two approaches as we move forward. Remember that scalar values in J do not have a shape of 0, but instead have a shape that is an empty list. Since there is no 0 in an empty list there is no change in representation of scalars.

Case 1 – A list of zero items – Shape 0


Old version

New version

Critique: Both versions have the axle indicating that this is a list and that items can be added. Both versions are also greyed out as a visual cue that this is an empty list. The new version shows that the dimension that is zero is along the x axis (the only axis, as indicated by the axle) and so this is an empty list, as opposed to an empty matrix or cube which we will see later. Even though this adds an element in the visualization of an empty array, it will provide a more simple representation of non-empty arrays.

Case 2 – A list of one item – Shape 1


Old version

New version

Critique: This is where the advantage of the new approach starts to appear. Instead of the extra horizontal line, only the line presenting the one dimensional shape is included. The colour indicates that the shape is non-zero immediately.

Case 3 – A matrix of one item – Shape 1 1


Old version

New version

Critique: The advantage continues as the plane immediately indicates the two dimensional shape and the single sphere indicates only one item. No extra lines required for the vast majority of arrays which are non-empty.

Case 4 – A cube of one item – Shape 1 1 1


Old version

New version

Critique: Again we have a single atom and the surrounding cube indicates three dimensions. The extra edges in the previous version are not required which really cleans up the display

Case 5 – A matrix of one item – Shape 0, Shape 0 1, and Shape 1, 0


Shape 0

Shape 0 1

Shape 1 0

Critique: The displays of these three empty arrays show that the one dimensional and two dimensional are clearly distinguishable, as is the difference between Shape 0 1 and Shape 1 0 matrices.

Case 6 – A cube of shape 1 2 3


Old version

New version

Critique: The spacing of the spheres easily shows the shape of the array and the enclosing cube outline immediately shows that the array has a three dimensional shape. If it were two dimensions the spheres would be embedded in a two dimensional plane. Again no more and no less than what is required to differentiate and describe the shape.

Case 7 – A cube of shape 0 2 3

Critique: This one was thrown in to show how a zero value in the leading axis of a three dimensional array would look. There are two rows and three columns of zero items which is why the spheres are greyed out with a front facing zero mark on the z axis. Contrast this with the 1 2 3 shape described in the preceding example.

Case 8 – A cube of shape 2 2 3


Old version

New version

Critique: I think that I may want to play around with the spacing on this one as this is one case where the new representation actually seems more confusing than the old version. Part of it may be the inherent structure that the extra edges provide, but I think this can be made up by using the spacing to reveal the relationships between the spheres as rows and columns. The text version of J uses this spacing to great effect, so I feel I am moving the right direction even though this version feels relatively unorganized.

In closing:

This time I promise; the next post will look at the representation of higher ranked arrays. I was happy to spend the extra time revising the display, as the higher dimensional representations really benefit from the cleaner look.  Until next time, I look forward to any feedback you may have.

Augmenting the Dual-View Array Representation

Follow Up:

My previous post included a verb to facilitate visualization of the Dual-View representation by returning coefficients representing array components:

   arrayCoeff =: +//.@(*/)/@,.&1

Unfortunately, this verb fails for scalars because it can’t deal with the empty list shape of rank 0 arrays.

   arrayCoeff ''
|domain error: arrayCoeff
|       arrayCoeff ''

A better solution has the array itself as the argument, then determines its shape and triggers an exception when dealing with scalars.

   arrayCoeffS =: +//.@(*/)/@,.&1`1:@.(''&-:)@$


 (''&-: )@$

returns 1 for a scalar argument.

   arrayCoeffS 4  NB. Scalar, array rank 0, shape ''
   arrayCoeffS 3 $ 4 NB. Vector, array rank 1, shape 3
3 1
   arrayCoeffS 2 3 $ 4 NB. Matrix, array rank 2, shape 2 3
6 5 1

Augmenting Frank’s Dual-View Representation:

This will allow arrays of shape 0 and shape 0 1 to be shown as distinct.
The Dual-View shows these shapes as identical because rank 2 can’t be represented by a single edge.

   arrayCoeffS 0$0 NB. Empty list of rank 1
0 1 

   arrayCoeffS 0 1$0 NB. No list of length 1 (rank 2)
0 1 1

Clearly they differ in the rank 2 array’s planar component, and changing the orientation of the single edge to indicate the plane is identical to the result of:

   arrayCoeffS 1 0$0 NB. One list of length 0 (rank 2)
0 1 1 

The way forward is to display the rank of the array even when the zero valued axes are not present. With distinguishable ranks, rank 1 and 2 arrays will be distinct. For rank 0 (scalar), the representation is the disk alone.

   arrayCoeffS 2 NB. Scalar value of 2 (rank 0)

Arrays of rank 1 have a horizontal line through the disk indicating that the list can add items either before or after the value. If the shape is 0, only this rank line is shown with an empty value – a greyed out disk.

A non-zero axis uses thicker edges with rank line extended.

Rank 2 arrays indicate rank as an x-y plane encompassing the disk, allowing axes indication without affecting rank representation.

With rank 3 the embedding structure is a cube, with potential axes in three dimensions.

By including the rank information the augmented Dual-View shows previously indistinguishable arrays distinctly:


   0 1 $ 0 

   1 0 $ 0 

While typical arrays display as expected.

   2 3 $ 0 

   2 2 3 $ 0 

In the next post I will look at the representation of higher ranked arrays. Until then, I look forward to any feedback you may have.

The ‘Dual-View’ approach to array visualization

Previously, we found the J text representation revealed values of individual atoms, but could not distinguish singleton arrays of different shapes, or empty arrays. Ron Frank in his paper, “A New “Dual-View” Diagram of Array Structure” (Frank, 2003) describes “Dual-View”, applying combinatorics to enumerate the atoms, lists, planes and cubes and representing them with dots and edges.

For example, an array of shape 2 3 4 has 2 * 3 * 4 = 24 atoms (T00); (2*3)+(3*4)+(2*4)=26 edges (T01); 2 + 3 + 4 = 9 planes (T02); and 1 cube (T03).

Edges and dots indicate planes and cubes by sketching the array in three dimensions. Collinear segments count as only one edge, so the diagram above has 24 dots for atoms, 26 edges for lists (12 aligned vertically, eight horizontally, and six along the z axis), nine planes (two parallel to the x-z plane, four parallel to the x-y plane and three parallel to the y-z plane), in a three dimensional brick.

This monadic J verb produces these coefficients given the shape of the array by stitching 1 to items of the shape, then cross multiplying (2 1) ⊗ (3 1) ⊗ (4 1) to produce coefficients.

   arrayCoeff =: (+//.@(*/))/@,.&1 
   arrayCoeff 2 3 4
24 26 9 1

For single valued arrays the added edges create distinct representations.

   arrayCoeff 1
1 1

   arrayCoeff 1 1
1 2 1

   arrayCoeff 1 1 1
1 3 3 1

Empty arrays have at least one zero in their shape. The list with shape zero is represented by a single edge with no dot as predicted.

   arrayCoeff 0
0 1

For higher ranked arrays, edges indicate placement of planes and cubes.

   arrayCoeff 2 3 0
0 6 5 1

Above we see an array of shape 2 3 0 with two planes parallel to the z-x plane (two pairs of three edges) and three planes parallel to the z-y plane (three groups of two).This representation conveys the empty array of shape 2 3 0 distinctly. A previous post illustrated that distinct orientations can represent shape permutations.

When more than one item in the shape is zero, for example shape 0 2 0, difficulties with the “Dual-View” crop up.

   arrayCoeff 0 2 0
0 0 2 1

As before we have zero atoms, but we also have zero edges – an invisible representation, making it impossible to distinguish arrays with more than one zero in their shape. In the next blog post I’ll introduce augmentations to the “Dual-View”, and although this improves the representation of array shapes, I must say the J text representation remains best for showing values of atoms.


Frank, Ronald I. (2003). A New ‘Dual View’ Diagram of Array Structure,
Proceedings of the ACM APL (SIGAPL), Federated Computer Research Conference (October 2003). ISBN 1 58113 668 4.

The new version of Lesson 3 Video Annotation

This is a new version of the Lesson 3 video annotation based on a suggestion by Raul Miller. Raul’s concern was that the previous version had too busy an animation. Why not do the operation across lists vertically by layering the lists instead of rotating from horizontal to vertical and back again. The advantages of this is that the animation is cleaner and quicker and the use of the assignment operator (=.) is not required. The challenge is that left argument mus be above the right argument for non-symmetrical operators such as Minus (-) and Divides (%) and the spacing of the columns depends on the width of the results. Let me know whether this version is an improvement. I look forward to your feedback/comments.

Cheers, bob

Video for Lesson 3 of Idiosyncratic Introduction to J

Well at least it did not take as long to get the video for Lesson 3 up and running. I took a slightly different approach here and animated the actual lines of J to show how the calculations take place. This is pretty straightforward for lists/vectors but may become more complicated when 2 dimensional arguments are used in the next lesson. I may need to draw on my experience with some of the NuVoc videos … and then again I may come up with something different again.

As always, comments and suggestions are welcome.

Cheers, bob