generate = function(n, m) 
	replicate(n, paste(sample(letters, m, replace=TRUE), collapse=""))

tests = list(

	wacek =
	function(data) {
		p = grep("^[^pq]*p", data)
		list(p=data[p], q=data[-p])
	},
	
	gabor1 =
	function(data) 
		sapply(c(p="^[^pq]*p", q="^[^pq]*q"), grep, x=data, value=TRUE),
		
	gabor2 =
	function(data)
		tapply(data, sub("^[^pq]*p(.).*", "\\1", data), c),
	
	gabor3 =
	function(data)
		tapply(data, substr(gsub("[^pq]", "", data), 1, 1), c),
	
	gabor4 =
	{ library(gsubfn); function(data)
		tapply(data, strapply(data, "^[^pq]*(.)", simplify=c), c) }
)
	
data = generate(1000,10)
lapply(names(tests), 
	function(name) {
		cat(name, ":\n", sep="")
		print(system.time(replicate(30,tests[[name]](data)))) } )
