This file contains hidden or 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
| (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. |
This file contains hidden or 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 my-function[lista] | |
| ((fn [num] (reverse num)) (map #(+ 10 %1) lista ))) | |
| (my-function `(1 2 3 4 5)) ; (15 14 13 12 11) |
This file contains hidden or 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 my-function[lista] | |
| (reverse (map #(+ 10 %1) lista ))) |
This file contains hidden or 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 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") |
This file contains hidden or 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
| (filter (fn [w] (> (count w) 2)) (re-split #"\W+" "A fine day")) |
This file contains hidden or 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
| (import 'javax.swing.JFrame) | |
| (def frame (JFrame. "Ola usando Java apartir de codigo Clojure")) | |
| (.setSize frame 200 200) | |
| (.setVisible frame true) |
This file contains hidden or 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
| Clojure 1.3.0 | |
| user=> (def y 10) | |
| #'user/y |
This file contains hidden or 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
| user=> (resolve `x) | |
| #'user/x |
This file contains hidden or 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
| user=> (in-ns 'myapp) | |
| #<Namespace myapp> | |
| myapp=> (in-ns 'myproject) | |
| #<Namespace myproject> | |
| myproject=> |
This file contains hidden or 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
| myproject=> (reverse "Casa") | |
| CompilerException java.lang.RuntimeException: Unable to resolve symbol: reverse in this context, compiling:(NO_SOURCE_PATH:4) |