]> Zhao Yanbai Git Server - acecode.git/commitdiff
...
authoracevest <zhaoyanbai@126.com>
Tue, 20 Jan 2015 08:22:13 +0000 (16:22 +0800)
committeracevest <zhaoyanbai@126.com>
Tue, 20 Jan 2015 08:22:13 +0000 (16:22 +0800)
learn/go/error.go [new file with mode: 0644]
learn/lex/a.l
learn/markdown/index.md [new file with mode: 0644]

diff --git a/learn/go/error.go b/learn/go/error.go
new file mode 100644 (file)
index 0000000..905bd59
--- /dev/null
@@ -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))
+}
index 1ef8160a6445058ce8c93a9f9c80a32f68e473f1..265702de36d373315d4383911b74908eeba3fd0c 100644 (file)
@@ -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 (file)
index 0000000..8bd5b3e
--- /dev/null
@@ -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 <stdio.h>
+int main() {
+       printf("Hello, World\n");
+       return 0;
+}
+```
+
+以下是水平分割线
+* * *  
+或
+***
+或
+*****
+或
+- - -  
+
+链接
+[Hello](http://www.qq.com)
+or
+[Tag][Link]
+[Link]: http://www.qq.com "sfasd"
+
+
+
+
+
+
+