Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- SHA512
- Clojure
- AES
- stringprintf
- Chrono
- sprintf
- Android
- program
- WebView
- ranges
- async
- traits
- c++
- Reflect
- SHA1
- go
- sha256
- kotlin
- template
- Observer
- Functional
- RAII
- type_traits
- design pattern
- Scala
- CustomTab
- haskell
- web
- coroutines
- ChromeTab
Archives
- Today
- Total
프로그래밍 검색 블로그
clojure java와 연결 본문
clojure 에서 자바와 연결하는 방법은
다른 모듈에 연결하는것처럼 할 수 있다
1 | (import java.util.Random) | cs |
일단 import로 추가를 선언해준뒤
1 2 3 | (let [rand (new Random)] (println (. rand nextInt)) (println (. rand nextInt 3)) ) | cs |
클래스 기반 구조라서 clojure에는 맞지 않을 수도 있는데
랜덤 클래스를 선언하고 nextInt를 호출하였다
이렇게 .을 호출하는 구조도 있고 이런 문법도 지원한다
1 2 3 | (let [rand (new Random)] (println (.nextInt rand)) (println (.nextInt rand 3))) | cs |
아직까지는 테스트 해본 모든 IDE에서 자동완성이 되는것 같지 않아
다른곳에서 복붙 하는 방식으로 피곤하게 작성하여야 했다
static 멤버의 경우에는 다음처럼 사용이 가능하다
1 | (println (. Integer parseInt "3")) | cs |
혹은
1 | (println (Integer/parseInt "3")) | cs |
'clojure기초' 카테고리의 다른 글
| clojue fibonacci / memoize (0) | 2017.10.29 |
|---|---|
| clojure 오버로딩 (0) | 2017.10.28 |
| clojure 함수형 프로그래밍 3 (apply) (0) | 2017.10.26 |
| clojure 함수형 프로그래밍 3 (range) (0) | 2017.10.22 |
| clojure 함수형 프로그래밍 2 (reduce, reduce-kv) (0) | 2017.10.22 |
Comments