cancel
Showing results for 
Search instead for 
Did you mean: 
SJT
Valued Contributor
Valued Contributor

A challenge for the weekend? Something from the Vector Dōjō…

A single-expression function to replace multiple embedded spaces in a string with single spaces. E.g.

 

q)rmeb "the    quick brown     fox"
"the quick brown fox"

 

If you find yourself writing a loop, you’re on the wrong track. This is not a golfing challenge, but my best lambda is 26 chars.

Extra kudos Find the fastest expression on a million-char string. 

Even more kudos To avoid typing it so often, you have a general filter function f:{y where x@y}. Define rmeb as a projection of f, using a composition as the left argument.

5 Comments
Contributors