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

Reply via email to