til
  • Introduction
  • Clojure
    • usage
    • lein
    • luminus
    • web
    • 4clojure
    • testing
  • Emacs-spacemacs
  • DB
    • mongodb
    • mysql
  • TDD study
    • 25장-테스트 주도 개발 패턴
    • 26-빨간막대패턴
    • 27-테스팅패턴
    • 28-초록막대패턴
    • 29-xUnit패턴
  • Util
  • Raft
    • 발표내용
    • 논문번역
  • Node.js
  • Security
    • 인코딩/디코딩
    • 암복호화 알고리즘
    • 공개키 알고리즘
  • 임시저장페이지
Powered by GitBook
On this page
  • loop & recur [미완]
  • 꼬리재귀
  • defn argument or 노테이션
  • schema 라이브러리
  • file이 있는지 확인하기
  • 어제 날짜 구하기 (clj-time사용)
  1. Clojure

usage

PreviousClojureNextlein

Last updated 6 years ago

loop & recur [미완]

  • loop은 recur의 대상점(기준점)이 됨, recur를 만나면 loop으로 가거나 현재 함수를 재귀로 부르거나.

  • loop은 let과 같은 형태로 인자를 받음

꼬리재귀

defn argument or 노테이션

schema 라이브러리

  • swagger와 함께 schema를 사용할 때, 정해지지 않은 맵을 내려주고 싶으면 다음과 같이 하면 된다.

(defschema body
  {s/Keyword s/Any})

  ...
  :return Body
  ...

file이 있는지 확인하기

> (require '[clojure.java.io :as io] )
> (.exists (io/as-file "test.txt"))

어제 날짜 구하기 (clj-time사용)

(:require [clj-time.core :as t])
;;어제
(t/minus (t/now) (t/days 1))

;;그제
(t/minus (t/now) (t/days 2))
https://github.com/plumatic/schema