You can determine the address ( 1;1;0 ) of the element you want to replace / fix using the monadic primitive map ( {:: :):
a=: 1 2 3;<4;<5 6;7 8 {:: a ┌───┬─────────────────────────┐ │┌─┐│┌─────┬─────────────────┐│ ││0│││┌─┬─┐│┌───────┬───────┐││ │└─┘│││1│0│││┌─┬─┬─┐│┌─┬─┬─┐│││ │ ││└─┴─┘│││1│1│0│││1│1│1││││ │ ││ ││└─┴─┴─┘│└─┴─┴─┘│││ │ ││ │└───────┴───────┘││ │ │└─────┴─────────────────┘│ └───┴─────────────────────────┘
The dyadic form {:: , fetch , will return an element from a nested structure.
(1;1;0) {:: a 5 6
Unfortunately, there is currently no }:: equivalent to modify ( } ), although there is a recent request to implement the primitive }:: in an interpreter that has the desired functionality.
While we expect this primitive to be implemented, a search through the archive of the J-programming forum showed a message that suggested the following recursive adverb that does what you asked for:
store=: adverb define : if.
I see that your question was also asked and answered on the J-forum . In the interest of completeness, I added a link to a more general solution .
(<123) [ applyintree (1;1;0) a ┌─────┬───────────────┐ │1 2 3│┌─┬───────────┐│ │ ││4│┌─────┬───┐││ │ ││ ││┌───┐│7 8│││ │ ││ │││123││ │││ │ ││ ││└───┘│ │││ │ ││ │└─────┴───┘││ │ │└─┴───────────┘│ └─────┴───────────────┘
source share