1. Yes, I should been more specific: I wanted to know the idiomatic way
to delete the nth item of a list, so I think <<< is what I was looking for.
What is <<< called and where is it documented?
2. Not sure what you mean by "Their focus is on micromanaging the
sequence of operations." A-lists are built into just about every other
modern language because they're so useful at managing information. Does
J not support JSON for web interoperability?
One example is using an a-list as a structured object, without having to
get into full-blown OO. I could represent the state of a model using an
a-list and then update the values over time.
I saw that using classes is one alternative
(https://rosettacode.org/wiki/Associative_array/Creation#J).
coclass'assocArray'
encode=:'z',(a.{~;48 65 97(+ i.)&.>10 26 26) {~62x #.inv256x #. a.&i.
get=: ".@encode
has=:0 <: nc@<@encode
set=:4 :'(encode x)=:y'
I have absolutely no idea what is going on in the encode function. I
hope there are other options.
On 12/03/2017 12:59 PM, Raul Miller wrote:
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,
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm