Created
September 21, 2010 20:01
-
-
Save lastk/590421 to your computer and use it in GitHub Desktop.
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
(defn multiplicar [ x y] (* x y) ) | |
; atribuir multiplicar para uma variável | |
(def m multiplicar) | |
;agora posso chamar multiplicar | |
(multiplicar 2 2) | |
;ou | |
(m 2 2) | |
(defn mult_soma_um [ z x y ] (+ 1 (z x y)) ) | |
;chamo a função mult_soma_um passando uma funcao como parâmetro | |
(mult_soma_um m 3 5) | |
;Retorna 16 |
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
//Scala | |
def multiplicar(x:Int,y:Int):Int = { | |
return x*y | |
} | |
var m = (x:Int,y:Int) => x * y | |
m(3,2) //retorna 6 | |
def mult_soma_um(f:(Int,Int)=>Int,a:Int,b:Int):Int = { | |
(f(a,b)+1) | |
} | |
println(mult_soma_um(m,3,2)) //retorna 7 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment