lua-users home
lua-l archive

Re: pipeing fucntions

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


There are better (more general but more complex) solutions.
First, you can do function composition :
function a(f)
 return function(x)
	return f(x) .. "a"
 end
end
function b(f)
 return function(x)
	return f(x) .. "b"
 end
end
f=b(a(function(x) return x end))
print(f"t")
Or you can use coroutines to implement filters.
Note: in both cases, the processing will be done sequentially, not
simultaneously in multiple cores.
If you really need multi-threading, you will need to deal with native
OS threads.

AltStyle によって変換されたページ (->オリジナル) /