Oh by the way... I've also released a companion addon called 'format/zulu-lite' .
This is just like 'format/zulu', except it omits the sandbox, with its sample data and app. It's for people who want to use the converter-verbs in their own code. Which you'd do by: require 'format/zulu-lite' That won't mean much to you unless you've run the lab which comes with the "sandbox". You'll remember a recent thread where I asked about loading (or requiring) an addon in a choice of different modes (which caused a lot of head-scratching)? Well, this is the way I've chosen to do it. Ian On Mon, Sep 17, 2012 at 2:36 AM, Ian Clark <earthspo...@gmail.com> wrote: > @Emir > A big Thank-you for your set of sample tasks from a bona-fide J > beginner. They come at the right time for me. > > I have just released a new addon: "format/zulu". This offers a > "sandbox" for experimenting with strings in J. It also installs a new > "Lab". See (in j602): > Menu: Studio > Labs... > Category: format > Strings conversion package > ...which puts the sandbox through its paces. > (Sorry, I can't see the Lab in J701. Maybe it's because I can't see > any "format" category. So you may have to install and run j602 instead > of j701.) > > Near the end of the Lab, viz at: > ── (31 of 39) TASKS > there's a set of sample tasks with boxed strings. They're much like > yours. Plus my own solutions. (But, I have to admit, my solutions are > not as slick as Raul's.) > > Nevertheless "zulu" might be of help to you. I offer it to you (and > other beginners) in that vein. Your feedback will help me to improve > the Lab. > > @Raul > Thank you for your solutions to Emir's tasks. Most timely. > As a result I'm going to use some of them in zulu.ijt, if you don't mind. > And if you get time to cast your eye over "format/zulu" I'd welcome > your suggestions. > (Other J-ers, too, especially those teaching J to beginners.) > > NB. "format/zulu" is very much aimed at beginners, especially its Lab. > I expect a Jmaster will die of boredom working thru it. > > On Sun, Sep 16, 2012 at 9:01 PM, Raul Miller <rauldmil...@gmail.com> wrote: >> s =: ' ';'this';'is';'a';'sentence' >> (<'is') 0} s >> ┌──┬────┬──┬─┬────────┐ >> │is│this│is│a│sentence│ >> └──┴────┴──┴─┴────────┘ >> 4 ({.,(<'sample'),}.) s >> ┌─┬────┬──┬─┬──────┬────────┐ >> │ │this│is│a│sample│sentence│ >> └─┴────┴──┴─┴──────┴────────┘ >> 1 }. s >> ┌────┬──┬─┬────────┐ >> │this│is│a│sentence│ >> └────┴──┴─┴────────┘ >> (2 {. s), 3 }.s >> ┌─┬────┬─┬────────┐ >> │ │this│a│sentence│ >> └─┴────┴─┴────────┘ >> (<'the') (I. s = <,'a')} s >> ┌─┬────┬──┬─┬────────┐ >> │ │this│is│a│sentence│ >> └─┴────┴──┴─┴────────┘ >> (<'the') (I. s = <'a')} s >> ┌─┬────┬──┬───┬────────┐ >> │ │this│is│the│sentence│ >> └─┴────┴──┴───┴────────┘ >> s -. <'is' >> ┌─┬────┬─┬────────┐ >> │ │this│a│sentence│ >> └─┴────┴─┴────────┘ >> >> In other words: >> >> 1) yes >> 2) yes >> 3) yes, but be careful >> >> In this case, your s contained five boxes. Four of those boxes where >> character sequences. One of them was just a character. In the >> general case, you need to be aware of the distinction between a >> character (rank 0) and a sequence of characters (rank 1), and you >> especially need to be aware of the distinction between a character and >> a sequence of characters of length 1. They're different but seem to >> be the same. >> >> This is analogous to the distinction between >> 2 >> and >> 3 4 5 >> >> The first is just a number, the second is a sequence of numbers... >> And you can have sequences of numbers of length 1, but that's not >> quite the same thing as the number by itself. >> >> -- >> Raul >> >> On Sun, Sep 16, 2012 at 3:30 PM, Emir Ustamujic <emir_...@yahoo.com> wrote: >>> Hello, >>> >>> As I'm often working with boxes of strings I have identified several things >>> that I would like to do with boxed strings but haven't figured how to do >>> yet as I'm still learning J. >>> >>> [I hope the boxes in the examples don't turn out garbled...] >>> >>> >>> 1. If there is a list of boxed words(strings) how to replace individual >>> items with another string ? >>> >>> For example I have : >>> ] s =: ' ';'this';'is';'a';'sentence' >>> ┌─┬────┬──┬─┬────────┐ >>> │ │ this│ is│a│ sentence│ >>> └─┴────┴──┴─┴────────┘ >>> but would like to use something like: 0 boxitemreplace s; 'is' (to replace >>> the first element which can be a space with 'is) >>> and get this result : >>> ┌──┬────┬──┬─┬────────┐ >>> │is │this │is │a │sentence │ >>> └──┴────┴──┴─┴────────┘ >>> or something like 2 boxitemreplace s;' ' (to replace the third element with >>> a space) >>> ┌──┬────┬──┬─┬────────┐ >>> │ │this │ │a │sentence │ >>> └──┴────┴──┴─┴────────┘ >>> >>> 2. Insert and Remove >>> >>> For example using the same s =: ' ';'this';'is';'a';'sentence': >>> would it be possible to somehow insert a word at a specific index so: 4 >>> inserttobox s;'sample' >>> would yield >>> ┌─┬────┬──┬─┬──────┬────────┐ >>> │ │this │is │a │sample │sentence │ >>> └─┴────┴──┴─┴──────┴────────┘ >>> or remove nth item such as 0 removeitemfrombox s;' ' >>> ┌────┬──┬─┬──────┬────────┐ >>> │this │is │a │sample │sentence │ >>> └────┴──┴─┴──────┴────────┘ >>> >>> >>> 3. And consequently would it be also possible to replace all occurences of >>> one string value within s with another string and remove all occurences of >>> one string from a boxed list such as s ? >>> >>> I more or less know how to do this with regular strings such as s=: 'this >>> is a sentence' but my problem is when dealing directly with boxed strings >>> and when they contain spaces. >>> >>> >>> Thanks &Regards, >>> Emir >>> ---------------------------------------------------------------------- >>> 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