Simply put, destructuring in Clojure is a way extract values from a datastructure and bind them to symbols, without having to explicitly traverse the datstructure. It allows for elegant and concise Clojure code.
(defn handler | |
[] | |
(println "HANDLER")) | |
(defn wrap-1 | |
[handler] | |
(fn [request] | |
(println 1) | |
(handler request) |
Lisp, the original high-level language, introduced a long list of features common in languages today, including dynamic typing, interpretation, and garbage collection. The original Lisp language is long gone, but it had many imitators, which we call 'dialects' of Lisp. Clojure, introduced in 2007, is the first Lisp dialect to gain wide usage in three decades.
Though Lisp features have been co-opted by many other languages, what still distinguishes Lisp dialects from all other languages is how Lisp dialects translate source code into running programs. In non-Lisp languages, the code translation process has two primary steps:
- lexing (a.k.a. tokenization) and parsing
- code generation (compilation or interpretation)
- AngularU Server Rendering Presentation (6/25/2015): https://www.youtube.com/watch?v=0wvZ7gakqV4
- AngularConnect Full Stack Angular 2 Presentation (10/20/2015): https://www.youtube.com/watch?v=MtoHFDfi8FM
- 원문: http://www.nurkiewicz.com/2016/06/functor-and-monad-examples-in-plain-java.html
- 작성자: Tomasz Nurkiewicz
이 글은 우리가 쓴 책, 'Reactive Programming with RxJava' 의 부록이었다. Reactive programming과 관련이 깊은 주제긴 하지만 모나드를 소개한다는 게 책과 썩 어울리지는 않았다. 그래서 나는 따로 블로그에 올리기로 했다. 프로그래밍을 다루는 블로그에서 *"반은 맞고 반은 틀릴 지 모르는 나만의 모나드 설명"*이란 것이 새로운 *"Hello World"*라는 점을 나도 잘 안다. 하지만 이 글은 펑터(functor)와 모나드(monad)를 자바 자료 구조와 라이브러리라는 각도에서 바라보고 있으며, 이는 공유할 정도의 가치는 있을거라 생각했다.
Many programming languages are designed to favour writing code over writing literal data. For example, in Python the syntax for accessing an instance variable on an object is:
student.name
But to access a value in a dictionary data structure:
(ns hub.db | |
(:require [clojure.tools.logging :as log] | |
[clojure.java.jdbc :as jdbc] | |
[mount.core :refer [defstate]] | |
[cheshire.core :refer [parse-string generate-string]] | |
[config.core :refer [env]] | |
[hub.util :as util] | |
[honeysql.core :as sql] | |
[honeysql.helpers :refer [merge-where]]) | |
(:import [java.sql PreparedStatement] |