wrt int1:

([ < {:@]) can be replaced by (<{:)
and 
({.@] < [) by (>{.)

so you get 
int1=: (>{.) *. (<{:)

 which is (IMO) more elegant.

Notice 
   9 int2 4 9
1
   9 int1 4 9
0
since in int2 you use >: instead of >
compare

   9 ([: ~:/ >/~)4 9
0


Starting with int1 you get
(>{.) *. (<{:)  is equivalent to 
(>{.) = (<{:)  assumed ({.<: {:)@] , which is equivalent to
(>{.) ~: (>:{:)  

If you replace the last expression with the inequivalent 
(>:{.) ~: (>:{:)  which is equivalent to
[: ~:/ >:/~


R.E. Boss


> -----Oorspronkelijk bericht-----
> Van: programming-boun...@jsoftware.com 
> [mailto:programming-boun...@jsoftware.com] Namens Gian Medri
> Verzonden: maandag 18 juni 2012 11:15
> Aan: programming@jsoftware.com
> Onderwerp: [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