josh@klaatu.rutgers.edu (J Storrs Hall) (01/10/91)
In article <1991Jan9.171347.19535@jato.jpl.nasa.gov>, sam@kalessin.jpl.nasa.gov (Sam Sirlin) writes: > I've not been able to find a way to do the equivalent of reassignment: > A[I] .is X > in J. Is this really impossible? Yes and no. J seems to adhere to some functional language purity standards to the extent of not allowing destructive modification of existing data structures. However the effect can easily be achieved with dyadic merge: A =. X I} A (which is a bit more powerful than reassignment in that it allows you the option of computing the value without modifying A). --JoSH
sam@kalessin.jpl.nasa.gov (Sam Sirlin) (01/11/91)
In article <Jan.9.14.25.50.1991.8808@klaatu.rutgers.edu>, josh@klaatu.rutgers.edu (J Storrs Hall) writes: ... |> |> A =. X I} A |> |> (which is a bit more powerful than reassignment in that it allows you |> the option of computing the value without modifying A). |> |> --JoSH Thanks! I looked at merge, but the description is so obscure that I didn't see this simple application. I'm just beginning to understand the boxing necessary in I for indexing. It seems much more complicated than the indexing function from APL 75 (the model for this?). This way of changing values is also less powerful than reassignment, since a duplicate copy of the whole array must be created (unless the language recognizes the idom), which could take substantial memory and time. Of course this mainly affects slow machines with little memory. You also need more characters for both the indexing ( A[2;3] versus (<2;3){a ). and the copy of "A." -- Sam Sirlin Jet Propulsion Laboratory sam@kalessin.jpl.nasa.gov