diff --git a/examples/ch1-01/hello/hello.go b/examples/ch1-01/hello/hello.go deleted file mode 100644 index dbf73ed..0000000 --- a/examples/ch1-01/hello/hello.go +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -package main - -import "fmt" - -func main() { - fmt.Println("你好, 世界!") -} diff --git a/examples/ch1-02/hello-alef/hello.alef b/examples/ch1-02/hello-alef/hello.alef deleted file mode 100644 index 6c864c8..0000000 --- a/examples/ch1-02/hello-alef/hello.alef +++ /dev/null @@ -1,19 +0,0 @@ -#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-02/hello-b/main.b b/examples/ch1-02/hello-b/main.b deleted file mode 100644 index e77f5c3..0000000 --- a/examples/ch1-02/hello-b/main.b +++ /dev/null @@ -1,8 +0,0 @@ -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-02/hello-c-01/hello-c-01.c b/examples/ch1-02/hello-c-01/hello-c-01.c deleted file mode 100644 index 5144cb4..0000000 --- a/examples/ch1-02/hello-c-01/hello-c-01.c +++ /dev/null @@ -1,4 +0,0 @@ -main() -{ - printf("hello, world"); -} diff --git a/examples/ch1-02/hello-c-02/hello-c-02.c b/examples/ch1-02/hello-c-02/hello-c-02.c deleted file mode 100644 index eaab7bb..0000000 --- a/examples/ch1-02/hello-c-02/hello-c-02.c +++ /dev/null @@ -1,4 +0,0 @@ -main() -{ - printf("hello, world\n"); -} diff --git a/examples/ch1-02/hello-c-03/hello-c-03.c b/examples/ch1-02/hello-c-03/hello-c-03.c deleted file mode 100644 index 8626b30..0000000 --- a/examples/ch1-02/hello-c-03/hello-c-03.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -main() -{ - printf("hello, world\n"); -} diff --git a/examples/ch1-02/hello-c-04/hello-c-04.c b/examples/ch1-02/hello-c-04/hello-c-04.c deleted file mode 100644 index 1aed89f..0000000 --- a/examples/ch1-02/hello-c-04/hello-c-04.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -main(void) -{ - printf("hello, world\n"); -} diff --git a/examples/ch1-02/hello-go-200806/hello.go.txt b/examples/ch1-02/hello-go-200806/hello.go.txt deleted file mode 100644 index ac52ff5..0000000 --- a/examples/ch1-02/hello-go-200806/hello.go.txt +++ /dev/null @@ -1,8 +0,0 @@ -// +build ignore - -package main - -func main() int { - print "hello, world\n"; - return 0; -} diff --git a/examples/ch1-02/hello-go-20080627/hello.go.txt b/examples/ch1-02/hello-go-20080627/hello.go.txt deleted file mode 100644 index f5ddc15..0000000 --- a/examples/ch1-02/hello-go-20080627/hello.go.txt +++ /dev/null @@ -1,7 +0,0 @@ -// +build ignore - -package main - -func main() { - print "hello, world\n"; -} diff --git a/examples/ch1-02/hello-go-20080811/hello.go.txt b/examples/ch1-02/hello-go-20080811/hello.go.txt deleted file mode 100644 index 67fcaad..0000000 --- a/examples/ch1-02/hello-go-20080811/hello.go.txt +++ /dev/null @@ -1,5 +0,0 @@ -package main - -func main() { - print("hello, world\n"); -} diff --git a/examples/ch1-02/hello-go-20081024/hello.go.txt b/examples/ch1-02/hello-go-20081024/hello.go.txt deleted file mode 100644 index 85051d0..0000000 --- a/examples/ch1-02/hello-go-20081024/hello.go.txt +++ /dev/null @@ -1,9 +0,0 @@ -// +build ignore - -package main - -import "fmt" - -func main() { - fmt.printf("hello, world\n"); -} diff --git a/examples/ch1-02/hello-go-20090915/hello.go.txt b/examples/ch1-02/hello-go-20090915/hello.go.txt deleted file mode 100644 index 0cb5e81..0000000 --- a/examples/ch1-02/hello-go-20090915/hello.go.txt +++ /dev/null @@ -1,9 +0,0 @@ -// +build ignore - -package main - -import "fmt" - -func main() { - fmt.Printf("hello, world\n"); -} diff --git a/examples/ch1-02/hello-go-20091211/hello.go b/examples/ch1-02/hello-go-20091211/hello.go deleted file mode 100644 index c2fbf9c..0000000 --- a/examples/ch1-02/hello-go-20091211/hello.go +++ /dev/null @@ -1,7 +0,0 @@ -package main - -import "fmt" - -func main() { - fmt.Printf("hello, world\n") -} diff --git a/examples/ch1-02/hello-go-asm/hello.go b/examples/ch1-02/hello-go-asm/hello.go deleted file mode 100644 index 20addf0..0000000 --- a/examples/ch1-02/hello-go-asm/hello.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -package main - -func main() diff --git a/examples/ch1-02/hello-go-asm/hello_amd64.s b/examples/ch1-02/hello-go-asm/hello_amd64.s deleted file mode 100644 index 3bf0038..0000000 --- a/examples/ch1-02/hello-go-asm/hello_amd64.s +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -#include "textflag.h" -#include "funcdata.h" - -// "Hello World!\n" -DATA text<>+0(SB)/8,$"Hello Wo" -DATA text<>+8(SB)/8,$"rld!\n" -GLOBL text<>(SB),NOPTR,$16 - -// func main() -TEXT ·main(SB), $16-0 - NO_LOCAL_POINTERS - MOVQ $text<>+0(SB), AX - MOVQ AX, (SP) - MOVQ $16, 8(SP) - CALL runtime·printstring(SB) - RET diff --git a/examples/ch1-02/hello-go-cgo/hello.go b/examples/ch1-02/hello-go-cgo/hello.go deleted file mode 100644 index f2a04aa..0000000 --- a/examples/ch1-02/hello-go-cgo/hello.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -package main - -// #include -// #include -import "C" -import "unsafe" - -func main() { - msg := C.CString("Hello, World!\n") - defer C.free(unsafe.Pointer(msg)) - - C.fputs(msg, C.stdout) -} diff --git a/examples/ch1-02/hello-go-swig/hello.cc b/examples/ch1-02/hello-go-swig/hello.cc deleted file mode 100644 index f71d644..0000000 --- a/examples/ch1-02/hello-go-swig/hello.cc +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -#include - -void SayHello() { - std::cout << "Hello, World!" << std::endl; -} diff --git a/examples/ch1-02/hello-go-swig/hello.go b/examples/ch1-02/hello-go-swig/hello.go deleted file mode 100644 index dde2af5..0000000 --- a/examples/ch1-02/hello-go-swig/hello.go +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -// +build ignore - -package main - -import ( - hello "." -) - -func main() { - hello.SayHello() -} diff --git a/examples/ch1-02/hello-go-swig/hello.swigcxx b/examples/ch1-02/hello-go-swig/hello.swigcxx deleted file mode 100644 index ac0f3c5..0000000 --- a/examples/ch1-02/hello-go-swig/hello.swigcxx +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -%module main - -%inline %{ -extern void SayHello(); -%} diff --git a/examples/ch1-02/hello-go-v2/hello.go b/examples/ch1-02/hello-go-v2/hello.go deleted file mode 100644 index 7c2b866..0000000 --- a/examples/ch1-02/hello-go-v2/hello.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright © 2017 ChaiShushan . -// License: https://creativecommons.org/licenses/by-nc-sa/4.0/ - -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-02/hello-limbo/hello.limbo b/examples/ch1-02/hello-limbo/hello.limbo deleted file mode 100644 index dcd78cb..0000000 --- a/examples/ch1-02/hello-limbo/hello.limbo +++ /dev/null @@ -1,15 +0,0 @@ -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"); -} diff --git a/examples/ch1-02/hello-newsqueak/hello.newsqueak b/examples/ch1-02/hello-newsqueak/hello.newsqueak deleted file mode 100644 index 409e345..0000000 --- a/examples/ch1-02/hello-newsqueak/hello.newsqueak +++ /dev/null @@ -1 +0,0 @@ -print("Hello,", "World", "\n"); diff --git a/examples/ch1-02/prime-newsqueak/prime.newsqueak b/examples/ch1-02/prime-newsqueak/prime.newsqueak deleted file mode 100644 index d915c32..0000000 --- a/examples/ch1-02/prime-newsqueak/prime.newsqueak +++ /dev/null @@ -1,41 +0,0 @@ -// 向管道输出从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();