Thanks, I often assume that the best way to write a J program is to do things in as few passes and as few distinct verbs as possible, I see that this isn't always the case.
On 18 January 2017 at 00:37, Raul Miller <[email protected]> wrote: > Your > 'abc' ([ ,:&.:>"(1 0) (<\~ -@:#)~) 'arbitrary_string' > > or, perhaps > 'abc' (<@[ ,:&.> (<\~ -@:#)~) 'arbitrary_string' > > is what I would do for your spec here. > > The secondary spec - that the left argument be incorporated into the > definition generated by the \ adverb - is at odds with your > requirement that it be tacit. (It's actually possible, but the > roundabout mechanism is verbose and painful, among other things, or > also the language can be changed to introduce other alternatives.) > > Also, that (x v0 y) (x v1 y) (x v2 y) thing was a part of the > definition of a different primitive. > > I hope this helps, > > -- > Raul > > > > On Tue, Jan 17, 2017 at 12:09 PM, Mark Allen <[email protected]> wrote: > > I have the following line of J: > > > > > > _3 (<@:('key'&,:)\) 'arbitrary_string' > > > > ┌───┬───┬───┬───┬───┬───┐ > > > > │key│key│key│key│key│key│ > > > > │arb│itr│ary│_st│rin│g │ > > > > └───┴───┴───┴───┴───┴───┘ > > > > > > I would like to define it entirely tacitly, i.e. I want a verb *f *such > > that > > > > > > 'abc' f\ 'arbitrary_string' > > > > ┌───┬───┬───┬───┬───┬───┐ > > > > │key│key│key│key│key│key│ > > > > │arb│itr│ary│_st│rin│g │ > > > > └───┴───┴───┴───┴───┴───┘ > > > > > > and similarly. > > > > > > 'key2' f\ 'another_arbitrary_string' > > > > ┌────┬────┬────┬────┬────┬────┐ > > > > │key2│key2│key2│key2│key2│key2│ > > > > │anot│her_│arbi│trar│y_st│ring│ > > > > └────┴────┴────┴────┴────┴────┘ > > > > > > This can be done easily enough in a piecemeal fashion by first boxing the > > infixes of the RHS and then laminating the LHS with each of the infixes, > > i.e. > > > > > > 'abc' ([ ,:&.:>"(1 0) (<\~ -@:#)~) 'arbitrary_string' > > > > ┌───┬───┬───┬───┬───┬───┐ > > > > │abc│abc│abc│abc│abc│abc│ > > > > │arb│itr│ary│_st│rin│g │ > > > > └───┴───┴───┴───┴───┴───┘ > > > > > > however, after the special gerund form of amend: > > > > > > x (v0`v1`v2) } y <--> (x v0 y) (x v1 y) } (x v2 y) > > > > > > I'd expect that there was some equivalent way of writing my verb f above, > > e.g. something like > > > > > > 'abc' (-@:#@:[ ` <@:,: ` ])\ 'arbitrary_string' > > > > > > Is there any such way? > > ---------------------------------------------------------------------- > > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
