Why do you want to delete an item from a list? This is *not* a
rhetorical question - we have a variety of ways of removing items from
lists and to pick the correct mechanism we need to understand what you
are trying to accomplish.

To illustrate, here are a few examples:

list=: 2 3 4 5 7 8 9 10

   NB. delete specific elements
   list -. 3 5 7
2 4 8 9 10

   NB. delete based on a computation
   (0=1&p: list)#list
4 8 9 10

   NB. delete based on a range of indices
   (3&{.,6&}.) list
2 3 4 9 10

   NB. delete values at certain indices
   (<<<3 5 6){ list
2 3 4 7 10

And then there's operations (like outfix) which offer regular abstractions:
   3 ]\. list
5 7 8 9 10
2 7 8 9 10
2 3 8 9 10
2 3 4 9 10
2 3 4 5 10
2 3 4 5  7

Note that "delete from a list" is a dual of "select from a list" -
maybe a shift in perspective can help?

As for the lack of "a-lists" - again, why do you want them? Depending
on what you are trying to do, there's a lot of options. Their focus is
on micromanaging the sequence of operations, though, so you should not
expect the language to make most of your decisions for you, there
(unless of course you are working with a language which was
specifically designed with an "everything should be an a-list"
mentality - but that's not J).

Thanks,

-- 
Raul


On Sun, Dec 3, 2017 at 12:40 PM, Andrew Dabrowski <[email protected]> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to