Menu
Home
Create new Paste
Log in
Threading functions statically
Code
Theme: cobalt
Theme: eclipse
Theme: elegant
Theme: monokai
Theme: neat
Theme: night
Theme: rubyblue
import std.stdio; import std.traits; auto threadFuncs(T, F...)(T t, F f) { static if (f.length == 0) { return t; } else { return threadFuncs(f[0](t), f[1..$]); } } int toInt(double x) { return cast(int) x+1; } float toFloat(int x) { return cast(float) x+1; } void main() { writeln("Hello World!"); writeln(threadFuncs(42.01)); writeln(threadFuncs(42.01, &toInt, &toFloat)); }
Result:
Success
/
Return code: 0
Application output:
Hello World! 42.01 44
Paste info
Author:
Guest
Views:
152
Private:
no
Expires:
Never
Uploaded:
13.07.17 18:10
Votes
:
0
Tweet
Compilation
Compiler:
DMD 2.081.2 ( 2.081.2 )
Pointer size:
m64
Actions
Download
Raw
×
Confirm
Are you sure you want to delete this paste?
There's no way back!
×
Confirm
Reason