Skip to content

Instantly share code, notes, and snippets.

@pbackus
Created June 16, 2020 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pbackus/deda874eeddf587d938cb5d6213a0b84 to your computer and use it in GitHub Desktop.
Save pbackus/deda874eeddf587d938cb5d6213a0b84 to your computer and use it in GitHub Desktop.
Solution to Functional-Programming Exercise
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