Skip to content

Instantly share code, notes, and snippets.

View PlumpMath's full-sized avatar
🏠
Pro

PlumpMath

🏠
Pro
View GitHub Profile
;; http://www.slideshare.net/dahlmoon/numpy-20160519
;; (import [numpy [*]])
(import numpy)
(import math)
;; 1D 배열
;; 파이썬 : numpy.array([1,2,3])
(numpy.array [1 2 3] )
;; https://www.youtube.com/watch?v=SB9TWabor1k
;; http://docs.hylang.org/en/latest/language/api.html
;; http://docs.hylang.org/en/latest/language/api.html#defmacro
;;defmacro is used to define macros.
defmacro는 매크로를 정의하는 데 사용됩니다.
;;The general format is (defmacro name [parameters] expr).
일반적인 형식은 (defmacro name [parameters] expr)입니다.
;; The following example defines a macro that can be used to swap order of elements in code,
;; https://www.youtube.com/watch?v=SB9TWabor1k
;; http://docs.hylang.org/en/latest/language/api.html
;; http://docs.hylang.org/en/latest/language/api.html#defmacro
;;defmacro is used to define macros.
defmacro는 매크로를 정의하는 데 사용됩니다.
;;The general format is (defmacro name [parameters] expr).
일반적인 형식은 (defmacro name [parameters] expr)입니다.
;; The following example defines a macro that can be used to swap order of elements in code,
;; https://www.youtube.com/watch?v=SB9TWabor1k
(car (car (cdr (cdr '(apples oranges (pickles bananas)) ))))
;;=> 'pickles'
(cdr '(apples oranges (pickles bananas)) )
;;=> ('oranges' ('pickles' 'bananas'))
(cdr (cdr '(apples oranges (pickles bananas)) ))
;;=> (('pickles' 'bananas'))
(def pi 3.14159)
(def radius 10)
(* pi ;; 3.14159
(* radius radius) ;; 100
)
;;=> 314.159
;; ELISP
;; sort함수가 없어서 직접 정의해 만들어 주어야함.
(defun quicksort (lst)
"Implement the quicksort algorithm."
(if (null lst) nil
(let* ((spl (car lst))
(rst (cdr lst))
(smalp (lambda (x)
(< x spl))))
(append (quicksort (remove-if-not smalp rst))
M-x lexbind-mode
;; => Lexbind mode enabled
M-x lexbind-toggle-lexical-binding
;; => Lexical-binding enabled
lexical-binding
;; => t
(let ( (a 1) )
(let ( (F (lambda () (print a))) )
(funcall F) ))
;;=> 1
(let ((a 1))
(let ((f (lambda () (print a))))
(let ((a 2))
(funcall f) )))
(setq x 3)
;; lambda == Anonymous function?
(defun func (x)
"function"
'(lambda () x))
;; (funcall (func 10))
lexical-binding
;; => nil 이라면? (현재 상태는 Dynamic binding을 의미한다?)
;; lambda == Anonymous function?
(defun func (x)
"function"
'(lambda () x))
(setq wrapped_func (func 10))