Skip to content

Instantly share code, notes, and snippets.

View edipofederle's full-sized avatar
🏠
Working from home

Édipo Féderle edipofederle

🏠
Working from home
View GitHub Profile
(fn[x] (+ x 1)) ; Declaracao de um funcao anonima
; retorna algo como: #<user$eval963$fn__964 user$eval963$fn__964@cd70f7>
((fn[x] (+ x 1)) 10) ; Executando um função anonima, retorna 11.
(defn my-function[lista]
((fn [num] (reverse num)) (map #(+ 10 %1) lista )))
(my-function `(1 2 3 4 5)) ; (15 14 13 12 11)
(defn my-function[lista]
(reverse (map #(+ 10 %1) lista )))
(defn indexable-word? [word]
(> (count word) 2))
(use '[clojure.contrib.str-utils :only (re-split)])
(filter indexable-word? (re-split #"\W+" "A fine day it is")) ; ("fine" "day")
(filter (fn [w] (> (count w) 2)) (re-split #"\W+" "A fine day"))
(import 'javax.swing.JFrame)
(def frame (JFrame. "Ola usando Java apartir de codigo Clojure"))
(.setSize frame 200 200)
(.setVisible frame true)
Clojure 1.3.0
user=> (def y 10)
#'user/y
user=> (resolve `x)
#'user/x
user=> (in-ns 'myapp)
#<Namespace myapp>
myapp=> (in-ns 'myproject)
#<Namespace myproject>
myproject=>
myproject=> (reverse "Casa")
CompilerException java.lang.RuntimeException: Unable to resolve symbol: reverse in this context, compiling:(NO_SOURCE_PATH:4)