Skip to content

Instantly share code, notes, and snippets.

View c-yan's full-sized avatar

c-yan c-yan

View GitHub Profile
@c-yan
c-yan / 3日で出来るLLVM の誤字等
Created August 13, 2012 06:19
3日で出来るLLVM の誤字等
P.8
2.2.3 clang の1行目の「Objevtive-C」は「Objective-C」
また、2.2.2 では「ObjectiveC」となっていて表記が揺れている
P.9
2.2.6 compiler-rt の1行目の「lilbgcc」は「libgcc」
以下のアーキテクチャの「X86-64」は「x86-64」
P.16
3.3.2 lli の2行目の「distable-lazy」は「disable-lazy」
@c-yan
c-yan / gist:4421388
Last active December 10, 2015 10:29
きつねさんとおぼえるLLVM の誤字等
P.7
「仮想機械としてのLLVM Core」5行目、「LLVM Core は受けたとった LLVM IR」は「LLVM Core は受けとった LLVM IR」の誤記だと思われる
「コンパイラ基盤としてのLLVM Core」3行目、「ユーザは LLVM は」は「ユーザは LLVM を使って」くらいの文意の誤記だと思われる
@c-yan
c-yan / gist:5327192
Created April 6, 2013 18:54
1987/6/30 ~ 2013/4/5 の間に全ての数字が異なる日がないことを確認する
>>> import datetime
>>> x = datetime.datetime(1987, 6,30)
>>> while True:
... x += datetime.timedelta(days = 1)
... t = str(x.year) + str(x.month) + str(x.day)
... if len(t) == len(list(set(t))):
... break
...
>>> print x
2013-04-05 00:00:00
@c-yan
c-yan / exercise-equivalent-binary-trees.go
Created January 18, 2018 21:54
[A Tour of Go] Exercise: Equivalent Binary Trees
package main
import "fmt"
import "golang.org/x/tour/tree"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
if t.Left != nil {
Walk(t.Left, ch)
@c-yan
c-yan / exercise-images.go
Created January 18, 2018 21:56
[A Tour of Go] Exercise: Images
package main
import "golang.org/x/tour/pic"
import "image"
import "image/color"
type MyImage struct {
w int
h int
v uint8
@c-yan
c-yan / exercise-rot-reader.go
Created January 18, 2018 21:58
[A Tour of Go] Exercise: rot13Reader
package main
import (
"io"
"os"
"strings"
)
type rot13Reader struct {
r io.Reader
@c-yan
c-yan / exercise-errors.go
Created January 18, 2018 22:02
[A Tour of Go] Exercise: Errors
package main
import (
"fmt"
)
type ErrNegativeSqrt float64
func (e ErrNegativeSqrt) Error() string {
return fmt.Sprintf("cannot Sqrt negative number: %v", float64(e))
@c-yan
c-yan / exercise-stringer.go
Created January 18, 2018 22:03
[A Tour of Go] Exercise: Stringers
package main
import "fmt"
import "strings"
type IPAddr [4]byte
func (a IPAddr) String() string {
tmp := make([]string, 4, 4)
for i, v := range a {
@c-yan
c-yan / exercise-fibonacci-closure.go
Created January 18, 2018 22:05
[A Tour of Go] Exercise: Fibonacci closure
package main
import "fmt"
// fibonacci is a function that returns
// a function that returns an int.
func fibonacci() func() int {
i := 0
j := 1
return func() int {
@c-yan
c-yan / exercise-maps.go
Created January 18, 2018 22:06
[A Tour of Go] Exercise: Maps
package main
import (
"golang.org/x/tour/wc"
"strings"
)
func WordCount(s string) map[string]int {
t := strings.Split(s, " ")
result := map[string]int{}