This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// このintSeqの関数はintSeqのbodyで定義されたanonymous functionを返します。帰ってくる関数はclosureを作るために変数iを含んでいます。 | |
func intSeq() func() int { | |
i := 0 | |
return func() int { | |
i += 1 | |
return i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// この関数は基礎であるfact(0)にたどり着くまで自分自身を呼び続けます。 | |
func fact(n int) int { | |
if n == 0 { | |
return 1 | |
} | |
return n * fact(n-1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github = Github() | |
github.issue_comment('comment that you post in PR thread') | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
// zeroval, zeroptrの2つの関数を値と比較してポインタがどのように動くかを見ていきます。zerovalはintのパラメータを持っています。引数が渡される事によってパラメータに代入されます。zerovalは呼ばれた関数の中の変数とは違うivalのコピーを得ます。 | |
func zeroval(ival int) { | |
ival = 0 | |
} | |
// zeroptrは対照的に*intがパラメータです。これは、intのポインタをパラメータとして取ることを意味します。関数のbody中の*iptr参照先の値をメモリアドレスを参照しそのアドレスの現在の値を取得します。ポインターを参照して代入される値は参照された値を変更します。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
import "math" | |
// 幾何学的な形の基本的なインターフェースです。 | |
type geometry interface { | |
area() float64 | |
perim() float64 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ brew install elasticsearch | |
$ elasticsearch -v | |
Version: 1.4.4, Build: c88f77f/2015-02-19T13:05:36Z, JVM: 1.7.0_72 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> # Let's create lists | |
>>> colors = "red blue green yellow".split() | |
>>> colors | |
['red', 'blue', 'green', 'yellow'] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Lossy Counting" | |
from collections import defaultdict | |
class LossyCounting(object): | |
'Implemendation of Lossy Counting' | |
def __init__(self, epsilon): | |
self._n = 0 | |
self._count = defaultdict(int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
result = [] | |
for i in range(n): | |
s = i * i | |
result.append(s) | |
print sum(result) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
screen -ls | grep Detached | awk '{ print $1}'| xargs -L 1 -I % screen -S % -X quit |