/
index.xml
185 lines (141 loc) · 5.96 KB
/
index.xml
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>Logs</title>
<link>http://ccjeaty.github.io/</link>
<description>Recent content on Logs</description>
<generator>Hugo -- gohugo.io</generator>
<language>zh-CN</language>
<lastBuildDate>Thu, 10 Mar 2016 00:00:00 +0000</lastBuildDate>
<atom:link href="http://ccjeaty.github.io/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>mysql 管理</title>
<link>http://ccjeaty.github.io/FarBox/posts/mysql%E7%AE%A1%E7%90%86/</link>
<pubDate>Thu, 10 Mar 2016 00:00:00 +0000</pubDate>
<guid>http://ccjeaty.github.io/FarBox/posts/mysql%E7%AE%A1%E7%90%86/</guid>
<description><p>##重设<code>用户</code>密码
<code>sql
set password for 'fred'@'localhost'=password('passwd');
flush privileges;
</code></p>
</description>
</item>
<item>
<title>clojure functional programming</title>
<link>http://ccjeaty.github.io/blog/2016/01/05/clojure-functional-programming/</link>
<pubDate>Tue, 05 Jan 2016 16:31:07 +0800</pubDate>
<guid>http://ccjeaty.github.io/blog/2016/01/05/clojure-functional-programming/</guid>
<description>
<h1 id="clojure函数式编程:0ba14bcd112cc5275625c24eb59b1cb6">Clojure函数式编程</h1>
<p>[toc]</p>
<h2 id="函数:0ba14bcd112cc5275625c24eb59b1cb6">函数</h2>
<h3 id="一等函数:0ba14bcd112cc5275625c24eb59b1cb6">一等函数</h3>
<p>函数在clj里面是一等公民;指的是函数可以被当做普通数据对待,具有以下特性:</p>
<ul>
<li>可以按需创建</li>
<li>可以在数据结构中存储</li>
<li>可以当做函数实参</li>
<li>可以当做函数返回值</li>
</ul>
<p>这此特性可以为程序提供更多的灵活性.</p>
<h3 id="闭包:0ba14bcd112cc5275625c24eb59b1cb6">闭包</h3>
<ul>
<li>闭包指的是函数可以访问成员变量,一般需要函数A返回一个函数B,在返回函数B里持有函数A的成员变量,形成一个闭包。</li>
<li>也可以看做是<strong>函数定制</strong>的一种手段</li>
</ul>
<pre><code class="language-clojure">(defn repeat-n [n]
(fn [num] (* n num)))
(def repeat-2 (repeat-n 2))
(repeat-2 5) ;;=&gt; 10
</code></pre>
<h3 id="尾递归:0ba14bcd112cc5275625c24eb59b1cb6">尾递归</h3>
<p>尾递归顾名思义,是指在函数<strong>尾部</strong>进行了递归调用. 与一般的递归区别于返回方式&amp;资源释放.
一般递归需要依次返回,返回值是由首次调用函数返回的,资源需要返回后才能被释放.如递归调用函数A,A1调用A2最终返回值是由A2返回给A1,A1再返回给caller. 并且在A2执行时, A1的资源不会被释放.所以调用时要考虑递归层级问题,如果层级太深会发生堆栈溢出.
尾递归是在A2执行时,A1的资源会被释放,并且最终返回结果是由A2直接返回给caller.所以在调用时,不会出现溢出问题.
jvm并不支持尾递</p>
<pre><code class="language-clojure">;;一般递归
(defn pow [base exp]
&quot;计算base的exp次幂&quot;
(if (zero? exp)
1
(* base (pow base (dec exp))))
)
;;尾递归版本(clojure版本)
(defn pow (base exp)
(letfn [(kapow [base exp sum]
(if (zero? exp)
sum
(recure base (dec exp) (* base sum)))]
(kapow base exp 1)))
</code></pre>
</description>
</item>
<item>
<title></title>
<link>http://ccjeaty.github.io/blog/1/01/01/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>http://ccjeaty.github.io/blog/1/01/01/</guid>
<description>
<h2 id="idea-常用快捷键:9370b07488e3c509d0007b32c081e4f1">Idea 常用快捷键</h2>
<p>[TOC]</p>
<h3 id="文本操作类:9370b07488e3c509d0007b32c081e4f1">文本操作类</h3>
<table>
<thead>
<tr>
<th>文件搜索</th>
<th><code>C-F</code> / <code>C-R</code></th>
</tr>
</thead>
<tbody>
<tr>
<td>anywhere</td>
<td>Shift + Shift (注意输入法切换冲突)</td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</description>
</item>
<item>
<title></title>
<link>http://ccjeaty.github.io/blog/1/01/01/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>http://ccjeaty.github.io/blog/1/01/01/</guid>
<description>
<h1 id="test:b128b7694e4de962e0088bcb1bcb254f">Test</h1>
<h2 id="todo:b128b7694e4de962e0088bcb1bcb254f">TODO</h2>
<pre><code class="language-clojure">(defn test [size]
(map #(prn %) size))
</code></pre>
<blockquote>
<p>zhongwen I&rsquo;m e</p>
</blockquote>
</description>
</item>
<item>
<title></title>
<link>http://ccjeaty.github.io/blog/1/01/01/</link>
<pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
<guid>http://ccjeaty.github.io/blog/1/01/01/</guid>
<description>
<h2 id="常用软件:b4a38f8649e643360eb52ee54aea7f6c">常用软件</h2>
<p>bubun</p>
<p>idea</p>
<p>typora markdown</p>
<p>listary</p>
<p>navicat</p>
</description>
</item>
</channel>
</rss>