2006/12/31, Roger Hui <[EMAIL PROTECTED]>:
enc=: 4 : 0
m=. (-2&|) +/ b=. x E. y
j=. (i.m)+(m$0,#x)+m$I. b
(m$'{}') j} (-.(i.m+#y) e. j)#^:_1 y
)
Nice. I didn't think of using "spread" here. I'd done it my way with
cut and connect the fragments, but yours is, of course, much neater.
[snip]
In such cases, the E. in enc needs to be replaced
by nos from the "Non-Overlapping Substrings" essay
http://www.jsoftware.com/jwiki/Essays/Non-Overlapping_Substrings
The use of transitive closure is truly enlightening. (I have your
"Some Uses of { and }" paper, too)
I take your code as a new year's gift. Thank you, Roger!
[snip]
----- Original Message -----
From: June Kim <[EMAIL PROTECTED]>
Date: Saturday, December 30, 2006 5:25 pm
Subject: [Jprogramming] text replacement without RE
> Could you come up with a verb enc, which encloses each substring that
> starts and ends with x in y without using RE? The substrings are
> discovered from the left.
>
> Example:
>
> 'foo' enc 'x xfoo x x xxfoo gogo foofoo barfoo'
> 'x x{foo x x xxfoo} gogo {foofoo} barfoo'
>
> Happy new year!
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm