Skip to content

Instantly share code, notes, and snippets.

@lastk
Created September 21, 2010 20:01
Show Gist options
  • Save lastk/590421 to your computer and use it in GitHub Desktop.
Save lastk/590421 to your computer and use it in GitHub Desktop.
(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
//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