Programming Lisp
     Clojure
  2   :




               :
           :   (   )
(   )




:
.


              .


(   ())           .
(Reader)
-
                            .

           (Reader Macro)
-
                                .
-                 ...
#(body %)       (fn [params*] body)

                             ;

  deref         @form        (deref form)

  meta    ...
(boolean) / nil          true, false

(character)                  a

   (keyword)              :tag, :doc

  (map)       ...
(symbol)

        .
-
-   (          )
-
-       : /(   ), .(       )
-                  (ref)



-                      .
(number)

-                                           .
-                                        BigDecimal(   M), BigInte...
(boolean) / nil
                         .


- ture, 0, () =
- false, nil =


- nil    false       .
- nil/false          ...
(character)
              .
-         ,    (     )                     .
-             (backspace),    (formfeed,         ...
(string)
                    .
-                           .
-                                          .


-            (...
(map)
  /                .
                                    (hash-code)
  .


-         {}           .
-{         }    ...
(keyword)
                                                .
-                                   .



-           (:)      ...
.
-                                                                    .



- (defn                                   [   ...
.



- (def         defn           var ) :    var           .(
  .)
- (var     )           #’       : var          .



- ...
:
                                 (name space)             .


-             =>


- (resolve      ):                     ...
.
-      (      )                      .


- {:                      }


-   (with-mata                                ): ...
.(
        )
- var       .


- #^
:
     if            /

    do

loop / recur

    for
if
                                .
-                           .



- (if (   )           )



- (if (< 50 0) "yes" "no"...
do

                                                          .


- (do            ....)


-   (if (< 50 0) (do (println "...
loop / recur
                        .
- loop : let                       recur              .
- recur : loop
       .



...
for

                                  .



- (for [                          ...]    )



- (for [file "ABC"] (format "%c"...
(boolean) / nil          true, false

(character)                  a

   (keyword)              :tag, :doc

  (map)       ...
:
if / (form?)       /

    do

loop / recur

    for
QnA
Upcoming SlideShare
Loading in …5
×

Programming Lisp Clojure - 2장 : 클로저 둘러보기

1,245 views

Published on

20101008 발표
아꿈사

Published in: Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,245
On SlideShare
0
From Embeds
0
Number of Embeds
37
Actions
Shares
0
Downloads
0
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Programming Lisp Clojure - 2장 : 클로저 둘러보기

  1. 1. Programming Lisp Clojure 2 : : : ( )
  2. 2. ( ) :
  3. 3. . . ( ()) .
  4. 4. (Reader) - . (Reader Macro) - . - .
  5. 5. #(body %) (fn [params*] body) ; deref @form (deref form) meta ^form (meta form) meda data meat data #^metadata form ‘form (quote form) form #”foo” => a java.util.regex.Pattern `x ~ ~@ var-quote #’x (var x)
  6. 6. (boolean) / nil true, false (character) a (keyword) :tag, :doc (map) {:name “Bill”, :age 42} (number) 1, 4.2 (string) “hello” (symbol) user/foo, java.lang.String
  7. 7. (symbol) . - - ( ) - - : /( ), .( ) - (ref) - .
  8. 8. (number) - . - BigDecimal( M), BigInteger . - BigDecimal . - . - : +, -, /, *, >, >=, <, = - : quot( ), rem( ) - 42 => 42 - [1 2 3] => [1 2 3] - (/ 22 7) => 22/7 - (/ 22.0 7) => 3.142857142857143 - (+) => 0 - (+ 1 (/ 0.00001M 1000000000000000000) ) => 1.00000000000000000000001M
  9. 9. (boolean) / nil . - ture, 0, () = - false, nil = - nil false . - nil/false ( list = ()/0 = zero) true . - : . (?) . ture . - (true? true) => true - (false? “foo”) => false - (zero? 0.0) => true - (nil? nil) => true - (if () “In Clojure” “in Common Lisp”) => “In Clojlure” - (if 0 “Zero” “NonZero”) => “Zero”
  10. 10. (character) . - , ( ) . - (backspace), (formfeed, ), (newline), (return), (space), (tab) . - - . - str : ( ) toString nil . - (str ) => - (str space ) => - (str backspace formfeed newline newline tab ) => b f n n t
  11. 11. (string) . - . - . - (“”) - . - interleave : . - apply str : interleave . . - take-nth :1 , . - (str 1 2 nil 3) => “123” - (apply str (take-nth 3 (apply str (interleave "Attack midnight" "The pur" "None")))) => “Atta”
  12. 12. (map) / . (hash-code) . - {} . -{ } . - def : , . - get : . . - (def names {“ ”“ ”}) => #‘user /names - (get names “ ”) => “ ” - (get names “ ”“ ”) => “ ”
  13. 13. (keyword) . - . - (:) . - defstruct : ( ) . - struct : . - struct-map : ( ) . - (def nations {: “ ”} => #‘user/nations - (nations : ) (: nations) => “ ” - (defstruct names : ) => #‘user/names - (struct names “ ”) => {: " "} - (struct-map names : “ ”) => {: " "}
  14. 14. . - . - (defn [ ...] ) : . & . - #( %1, %2 ... ) (fn [ ] ) : . - (defn get “return” [user] (str “Hello, “ user) (get “world”) => “Hello, world” - (defn get [hello] (fn [user] (str get “,” user))) (defn get2 (get “Hello”) (get2 “world” => “Hello, world”)
  15. 15. . - (def defn var ) : var .( .) - (var ) #’ : var . - (let [ ... ] ): .
  16. 16. : (name space) . - => - (resolve ): . - (in-ns ): . - (import ‘( )) : . . - (require ‘ ): . - (use ‘ ): . - (use :reload ‘ ): . - (use :reload-all ‘ ): . - (ns ): , :import, :require, :use . - (in-us ‘newworld) => newworld=>
  17. 17. . - ( ) . - {: } - (with-mata ): . - (identical? 1 2 ): . - (meta ) ^ : . - (assoc ....) : .
  18. 18. .( ) - var . - #^
  19. 19. : if / do loop / recur for
  20. 20. if . - . - (if ( ) ) - (if (< 50 0) "yes" "no") => “no” - when / when-not :
  21. 21. do . - (do ....) - (if (< 50 0) (do (println "haha") "yes") (do (println " ") (println "haha") "no")) => | haha | "no"
  22. 22. loop / recur . - loop : let recur . - recur : loop . - (loop [ ...] ) - (recur ...) - (loop [n [] x 5] (if (zero? x) (println n) (recur (conj n x) (- x 1)))) => [5 4 3 2 1] | nil
  23. 23. for . - (for [ ...] ) - (for [file "ABC"] (format "%c" file)) => ("A" "B" "C")
  24. 24. (boolean) / nil true, false (character) a (keyword) :tag, :doc (map) {:name “Bill”, :age 42} (number) 1, 4.2 (string) “hello” (symbol) user/foo, java.lang.String
  25. 25. : if / (form?) / do loop / recur for
  26. 26. QnA

×