From: acevest Date: Tue, 20 Jan 2015 08:22:13 +0000 (+0800) Subject: ... X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/man.dnssec-settime.html?a=commitdiff_plain;h=d043ee5b33d6de7e546e028c364811bf536dd2f9;p=acecode.git ... --- diff --git a/learn/go/error.go b/learn/go/error.go new file mode 100644 index 0000000..905bd59 --- /dev/null +++ b/learn/go/error.go @@ -0,0 +1,28 @@ +package main + +import ( + "fmt" +) + +type ErrNegativeSqrt float64 + +func (e ErrNegativeSqrt) Error() string { + return fmt.Sprintf("cannot Sqrt negative number: %g\n", float64(e)) +} + +func Sqrt(x float64) (float64, error) { + z := 1.0 + if x >= 0 { + for i := 0; i < 10; i++ { + z = z - (z*z-x)/(2*z) + } + } else { + return 0, ErrNegativeSqrt(x) + } + return z, nil +} + +func main() { + fmt.Println(Sqrt(2)) + fmt.Println(Sqrt(-2)) +} diff --git a/learn/lex/a.l b/learn/lex/a.l index 1ef8160..265702d 100644 --- a/learn/lex/a.l +++ b/learn/lex/a.l @@ -30,9 +30,9 @@ could | has | have | had | -go { printf("%s: is a verb\n", yytext); } -[a-zA-Z]+ { printf("%s: is not a verb\n", yytext); } -[0-9]+ { printf("%s: is a num\n", yytext); } +go { printf("%s: is a verb", yytext); } +[a-zA-Z]+ { printf("%s: is not a verb", yytext); } +[0-9]+ { printf("%s: is a num", yytext); } .|\n { ECHO; /* 通常的默认状态 */ } %% diff --git a/learn/markdown/index.md b/learn/markdown/index.md new file mode 100644 index 0000000..8bd5b3e --- /dev/null +++ b/learn/markdown/index.md @@ -0,0 +1,61 @@ +#这是H1# +##这是H2## +###这是H3### +#####这是H4#### +######这是H5##### +######这是H6###### + +vxcvzdfdsf +fsadfasdf +sfasdf + +> q adfads sdfads +> fa +> afdsfadfasdfasdfsadf +> sfa +> sdfasdf +> fs fsadf +> dsafsd +> fsdfa +> dsf +> sadfasd + + +这是一个*强调*示例,这是另一个 _强调_ 示例 +这是一个**加重强调**示例 或 __加重强调__ +这是一个***特别强调***示例 或 ___特别强调___ + + +这是个命令示例`echo "Hello World"` 输出什么? + + + +``` +#include +int main() { + printf("Hello, World\n"); + return 0; +} +``` + +以下是水平分割线 +* * * +或 +*** +或 +***** +或 +- - - + +链接 +[Hello](http://www.qq.com) +or +[Tag][Link] +[Link]: http://www.qq.com "sfasd" + + + + + + +