From 46d71f3b13a8731245755f3cfe39a472593886fc Mon Sep 17 00:00:00 2001 From: chai2010 Date: Sun, 16 Dec 2018 12:27:35 +0800 Subject: [PATCH] =?UTF-8?q?ch1.2:=20=E5=88=A0=E9=99=A4=E5=BA=9F=E5=BC=83?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- examples/ch1.2-1/hello.b | 10 -------- examples/ch1.2-10/hello.go | 10 -------- examples/ch1.2-11/hello.go | 9 ------- examples/ch1.2-12/hello.go | 7 ------ examples/ch1.2-13/hello.go | 11 -------- examples/ch1.2-14/hello.go | 9 ------- examples/ch1.2-15/hello.go | 9 ------- examples/ch1.2-16/main.go | 22 ---------------- examples/ch1.2-2/hello.c | 6 ----- examples/ch1.2-3/hello.c | 6 ----- examples/ch1.2-4/hello.c | 8 ------ examples/ch1.2-5/hello.c | 8 ------ examples/ch1.2-6/hello.newsqueak | 3 --- examples/ch1.2-7/prime.newsqueak | 43 -------------------------------- examples/ch1.2-8/hello.alef | 21 ---------------- examples/ch1.2-9/hello.limbo | 17 ------------- 16 files changed, 199 deletions(-) delete mode 100644 examples/ch1.2-1/hello.b delete mode 100644 examples/ch1.2-10/hello.go delete mode 100644 examples/ch1.2-11/hello.go delete mode 100644 examples/ch1.2-12/hello.go delete mode 100644 examples/ch1.2-13/hello.go delete mode 100644 examples/ch1.2-14/hello.go delete mode 100644 examples/ch1.2-15/hello.go delete mode 100644 examples/ch1.2-16/main.go delete mode 100644 examples/ch1.2-2/hello.c delete mode 100644 examples/ch1.2-3/hello.c delete mode 100644 examples/ch1.2-4/hello.c delete mode 100644 examples/ch1.2-5/hello.c delete mode 100644 examples/ch1.2-6/hello.newsqueak delete mode 100644 examples/ch1.2-7/prime.newsqueak delete mode 100644 examples/ch1.2-8/hello.alef delete mode 100644 examples/ch1.2-9/hello.limbo diff --git a/examples/ch1.2-1/hello.b b/examples/ch1.2-1/hello.b deleted file mode 100644 index ca9855d..0000000 --- a/examples/ch1.2-1/hello.b +++ /dev/null @@ -1,10 +0,0 @@ -// ch1.2-1 - -main() { - extrn a, b, c; - putchar(a); putchar(b); putchar(c); - putchar('!*n'); -} -a 'hell'; -b 'o, w'; -c 'orld'; diff --git a/examples/ch1.2-10/hello.go b/examples/ch1.2-10/hello.go deleted file mode 100644 index 03b9525..0000000 --- a/examples/ch1.2-10/hello.go +++ /dev/null @@ -1,10 +0,0 @@ -// chai2010.cn/gobook/examples/ch1.2-10 - -// +build ignore - -package main - -func main() int { - print "hello, world\n"; - return 0; -} diff --git a/examples/ch1.2-11/hello.go b/examples/ch1.2-11/hello.go deleted file mode 100644 index 2f260b6..0000000 --- a/examples/ch1.2-11/hello.go +++ /dev/null @@ -1,9 +0,0 @@ -// chai2010.cn/gobook/examples/ch1.2-11 - -// +build ignore - -package main - -func main() { - print "hello, world\n"; -} diff --git a/examples/ch1.2-12/hello.go b/examples/ch1.2-12/hello.go deleted file mode 100644 index 355b7ba..0000000 --- a/examples/ch1.2-12/hello.go +++ /dev/null @@ -1,7 +0,0 @@ -// go run chai2010.cn/gobook/examples/ch1.2-12 - -package main - -func main() { - print("hello, world\n") -} diff --git a/examples/ch1.2-13/hello.go b/examples/ch1.2-13/hello.go deleted file mode 100644 index ce3ed88..0000000 --- a/examples/ch1.2-13/hello.go +++ /dev/null @@ -1,11 +0,0 @@ -// go run chai2010.cn/gobook/examples/ch1.2-13 - -// +build ignore - -package main - -import "fmt" - -func main() { - fmt.printf("hello, world\n") -} diff --git a/examples/ch1.2-14/hello.go b/examples/ch1.2-14/hello.go deleted file mode 100644 index e6d4871..0000000 --- a/examples/ch1.2-14/hello.go +++ /dev/null @@ -1,9 +0,0 @@ -// go run chai2010.cn/gobook/examples/ch1.2-14 - -package main - -import "fmt" - -func main() { - fmt.Printf("hello, world\n") // ; -} diff --git a/examples/ch1.2-15/hello.go b/examples/ch1.2-15/hello.go deleted file mode 100644 index 8e98b74..0000000 --- a/examples/ch1.2-15/hello.go +++ /dev/null @@ -1,9 +0,0 @@ -// go run chai2010.cn/gobook/examples/ch1.2-15 - -package main - -import "fmt" - -func main() { - fmt.Printf("hello, world\n") -} diff --git a/examples/ch1.2-16/main.go b/examples/ch1.2-16/main.go deleted file mode 100644 index 649d4cd..0000000 --- a/examples/ch1.2-16/main.go +++ /dev/null @@ -1,22 +0,0 @@ -// go run chai2010.cn/gobook/examples/ch1.2-16 - -package main - -import ( - "fmt" - "log" - "net/http" - "time" -) - -func main() { - fmt.Println("Please visit http://127.0.0.1:12345/") - http.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) { - s := fmt.Sprintf("你好, 世界! -- Time: %s", time.Now().String()) - fmt.Fprintf(w, "%v\n", s) - log.Printf("%v\n", s) - }) - if err := http.ListenAndServe(":12345", nil); err != nil { - log.Fatal("ListenAndServe: ", err) - } -} diff --git a/examples/ch1.2-2/hello.c b/examples/ch1.2-2/hello.c deleted file mode 100644 index 634cf5b..0000000 --- a/examples/ch1.2-2/hello.c +++ /dev/null @@ -1,6 +0,0 @@ -// ch1.2-2 - -main() -{ - printf("hello, world"); -} diff --git a/examples/ch1.2-3/hello.c b/examples/ch1.2-3/hello.c deleted file mode 100644 index 8054f8f..0000000 --- a/examples/ch1.2-3/hello.c +++ /dev/null @@ -1,6 +0,0 @@ -// ch1.2-3 - -main() -{ - printf("hello, world\n"); -} diff --git a/examples/ch1.2-4/hello.c b/examples/ch1.2-4/hello.c deleted file mode 100644 index e3f9df7..0000000 --- a/examples/ch1.2-4/hello.c +++ /dev/null @@ -1,8 +0,0 @@ -// ch1.2-4 - -#include - -main() -{ - printf("hello, world\n"); -} diff --git a/examples/ch1.2-5/hello.c b/examples/ch1.2-5/hello.c deleted file mode 100644 index 519563b..0000000 --- a/examples/ch1.2-5/hello.c +++ /dev/null @@ -1,8 +0,0 @@ -// ch1.2-5 - -#include - -main(void) -{ - printf("hello, world\n"); -} diff --git a/examples/ch1.2-6/hello.newsqueak b/examples/ch1.2-6/hello.newsqueak deleted file mode 100644 index a0683cd..0000000 --- a/examples/ch1.2-6/hello.newsqueak +++ /dev/null @@ -1,3 +0,0 @@ -// ch1.2-6 - -print("Hello,", "World", "\n"); diff --git a/examples/ch1.2-7/prime.newsqueak b/examples/ch1.2-7/prime.newsqueak deleted file mode 100644 index 70e44a8..0000000 --- a/examples/ch1.2-7/prime.newsqueak +++ /dev/null @@ -1,43 +0,0 @@ -// ch1.2-7 - -// 向管道输出从2开始的自然数序列 -counter := prog(c:chan of int) { - i := 2; - for(;;) { - c <-= i++; - } -}; - -// 针对listen管道获取的数列,过滤掉是prime倍数的数 -// 新的序列输出到send管道 -filter := prog(prime:int, listen, send:chan of int) { - i:int; - for(;;) { - if((i = <-listen)%prime) { - send <-= i; - } - } -}; - -// 主函数 -// 每个管道第一个流出的数必然是素数 -// 然后基于这个新的素数构建新的素数过滤器 -sieve := prog() of chan of int { - c := mk(chan of int); - begin counter(c); - prime := mk(chan of int); - begin prog(){ - p:int; - newc:chan of int; - for(;;){ - prime <-= p =<- c; - newc = mk(); - begin filter(p, c, newc); - c = newc; - } - }(); - become prime; -}; - -// 启动素数筛 -prime := sieve(); diff --git a/examples/ch1.2-8/hello.alef b/examples/ch1.2-8/hello.alef deleted file mode 100644 index df4ef07..0000000 --- a/examples/ch1.2-8/hello.alef +++ /dev/null @@ -1,21 +0,0 @@ -// ch1.2-8 - -#include - -void receive(chan(byte*) c) { - byte *s; - s = <- c; - print("%s\n", s); - terminate(nil); -} - -void main(void) { - chan(byte*) c; - alloc c; - proc receive(c); - task receive(c); - c <- = "hello proc or task"; - c <- = "hello proc or task"; - print("done\n"); - terminate(nil); -} diff --git a/examples/ch1.2-9/hello.limbo b/examples/ch1.2-9/hello.limbo deleted file mode 100644 index 1f8a0d2..0000000 --- a/examples/ch1.2-9/hello.limbo +++ /dev/null @@ -1,17 +0,0 @@ -// ch1.2-9 - -implement Hello; - -include "sys.m"; sys: Sys; -include "draw.m"; - -Hello: module -{ - init: fn(ctxt: ref Draw->Context, args: list of string); -}; - -init(ctxt: ref Draw->Context, args: list of string) -{ - sys = load Sys Sys->PATH; - sys->print("hello, world\n"); -}