-
-
Save pbackus/deda874eeddf587d938cb5d6213a0b84 to your computer and use it in GitHub Desktop.
Solution to Functional-Programming Exercise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float myFun(SumType!(float, int, string, int[]) a) | |
{ | |
import std.functional: pipe; | |
return a.match!( | |
number => cast(float) number, | |
array => | |
array.process | |
.common1 | |
.pipe!((value) { | |
static if (is(typeof(array) == string)) | |
return special(array, value); | |
else | |
return value; | |
})) | |
.common2 | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment