Skip to content

Instantly share code, notes, and snippets.

@devboy
Created November 22, 2011 01:17
Show Gist options
  • Save devboy/1384581 to your computer and use it in GitHub Desktop.
Save devboy/1384581 to your computer and use it in GitHub Desktop.
function doMath( x: Float, y: Float, mathOperation: Float -> Float -> Float ) {
return mathOperation(x, y);
}
var addition = function(x: Float, y: Float) {
return x + y;
}
var square = function(x: Float) {
return x * x;
}
type( doMath ); // Float -> Float -> (Float -> Float -> Float) -> Float
doMath( 1, 2, addition ); // will return 3
doMath( 1, 2, square ); // compiler error: Float -> Float should be Float -> Float -> Float
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment