阿小信大人的头像
做你说过的,说你能做的 阿小信大人

clojure-koans练习笔记2016-05-19 12:09

#### strings笔记

**get**使用姿势

get returns a value mapped to key, not-found or nil if not present. So to get \C we have to pass in the index 0.

:::clojure
koan-engine.runner=> (get "asd" 0)
\a
koan-engine.runner=> (get "asd" 1)
\s
koan-engine.runner=> (get "asd" -1)

......
#Clojure#   评论[0]阅读全文[1018]

Clojure中defstruct、deftype和defrecord使用区别2016-05-17 16:43

#### defstruct

:::clojure
user=> (defstruct Point1 :x :y)
#'user/Point1
user=> (def p1 (struct-map Point1 :x 3 :y 4))
#'user/p1
user=> (prn p1)
{:x 3, :y 4}
nil
user=> (prn (:x p1))
3
nil
user=> (prn (struct-map Point1 3 5))
{:x nil,

......
#Clojure#   评论[0]阅读全文[1104]

[转]Clojure中require、use和import的区别2016-03-16 16:51

#### 关于require

require只负责引入clojure库,不绑定函数到当前的ns中。

:::clojure
;;引入java io,并指定缩略名为io
(require '[clojure.java.io :as io])
;;使用
(io/file "Filename")

;;在ns中使用
(ns test
(:require [clojure.java.io :as io]))

Require, 等同python import

#### 关于refer

将函

......
#Clojure#   评论[0]阅读全文[938]

hello clojure2016-03-16 16:45


#### install jdk

download and install jdk:

#### install lein

brew install leiningen

#### new project

lein new myapp

#### project tree

:::text
myapp
├── LICENSE
├── README.md
├── doc
│   └── intro.md
├── project.clj
├── resources

......
#Clojure#   评论[2]阅读全文[1068]