[Jprogramming] delete item; ass. lists

Erling Hellenäs erling at erlinghellenas.se
Sun Dec 3 19:06:34 UTC 2017


Hi all!

This touches one of the most interesting aspects of J.
Variables in J are normally non-mutable in the sense that they can not 
be modified in-place.
You can not set variable A to 1 2 3 and then change it to 1 3 without 
creating a new variable, but one which might have the same name.
This means that the answer to question 1. is "There is no way to delete 
an item from a list.". What you do is assigning the items you want to 
remain in the list to a new variable.
So, why is this interesting?
In functional programming we usually work with non-mutable variables. 
This means we can not even reassign a loop variable. Usually this means 
we work recursively. There are also lots of other tricks we use to 
transform one variable into another without doing it in small 
increments. J is filled with such tricks. This means, as I see it, that 
J should be interesting for functional programmers since it shows many 
ways to transform a variable into another without changing the variable 
incrementally.
Many APL/J tricks for this are now built into for example the array 
class in F#. There is scan, fold and map, for example. But as far as I 
know, many are still not widely used among other functional programmers. 
Agreement and Rank are some examples.

PS. There are some exceptions when J variables are changed in-place. DS.

Cheers,
Erling Hellenäs

On 2017-12-03 18:40, Andrew Dabrowski wrote:
> 1. What's the idiomatic way to delete an item from a list?  This 
> doesn't seem to come up in Learning J.  For that matter, what's a good 
> reference for list slicing ops in J?
>
> 2. Is anyone bothered by the lack of a built-in associative list 
> structure?  There are at least two different implementations in 
> Rosetta Code, but one is very bare-bones and the other uses classes, 
> which I'd prefer to avoid (I confess to having a bias against OO).  I 
> guess J people have found other substitutes for 
> dicts/hashes/maps/associative arrays.
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm




More information about the Programming mailing list