Just in case you didn't know, there is a standard function for string
substitution:

           require'strings'
           ('can be';'is') stringreplace_z_ 'Life can be good' 
        Life is good
           
-Dan

-----Original Message-----
From: programming-boun...@jsoftware.com
[mailto:programming-boun...@jsoftware.com] On Behalf Of Gian Medri
Sent: Monday, June 18, 2012 5:15 AM
To: programming@jsoftware.com
Subject: [Jprogramming] J-solutions

Hi!

I shall replace some text in a vector. My function is
Replace=:13 :'(p{.y),(>1{x),(($>0{x)+p=.I. (>0{x) E. y)}.y'
Example : ('can be';'is') Replace 'Life can be good'
Life is good
I would like to see if there is a better solution, more J-like.

I have also 2 functions for interval:
1) int1=:({.@] < [)*.([ < {:@])
 6 int1 4 9
1
This is very clear how it works.

2) int2=:[: ~:/ >:/~
This is more concise and elegant, but I don't understand how it works.
Can somebody  give me an explanation?
Thanks
Gian Medri
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to