Skip to content

Instantly share code, notes, and snippets.

@Titinx
Last active September 8, 2016 17:27
Show Gist options
  • Save Titinx/4c21570a64de9959c30b1dcbda1fa6af to your computer and use it in GitHub Desktop.
Save Titinx/4c21570a64de9959c30b1dcbda1fa6af to your computer and use it in GitHub Desktop.
-- *** Expression : curry
-- *** Of type : ((a,b) -> c) -> a -> b -> c
-- definicion where
myCurry f = g
where g x = h
where h y = f (x,y)
-- definicion "λ" - funcion anonima (Lambda):
myCurry' f = \x -> ( \y -> f (x,y) )
-- definicion currificada:
-- ((mycurry'' f) x) y = f (x,y)
-- como la aplicacion asocia a izquierda, es igual a:
myCurry'' f x y = f (x,y)
-- Probar con myCurry fst 3 2
-- *** Expression : uncurry
-- *** Of type : (a -> b -> c) -> (a,b) -> c
myUncurry f = g
where g (a,b) = f a b
myUncurry' f = \(a,b) -> (f a b)
myUncurry'' f (a,b) = f a b
-- Probar con myUncurry max (3,2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment