This repository has been archived by the owner on Mar 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cc3684e
Showing
78 changed files
with
475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2022, Journal of Hamradio Informatics | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Tutorial: Chapel the Parallel Programming Language | ||
==== | ||
|
||
 | ||
 | ||
|
||
[うさぎさんでもわかる並列言語Chapel (PDF)](https://nextzlog.dev/chpl.pdf) [(HTML)](https://nextzlog.dev/chpl) | ||
|
||
## Contribution | ||
|
||
Feel free to make issues at [nextzlog/todo](https://github.com/nextzlog/todo). | ||
Follow [@nextzlog](https://twitter.com/nextzlog) on Twitter. | ||
|
||
## License | ||
|
||
### Author | ||
|
||
[無線部開発班](https://nextzlog.dev) | ||
|
||
### Clauses | ||
|
||
[BSD 3-Clause License](LICENSE.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module Foo { | ||
writeln("initilize Foo"); | ||
proc main() { | ||
writeln("This is Foo"); | ||
} | ||
} | ||
module Bar { | ||
writeln("initilize Bar"); | ||
proc main() { | ||
writeln("This is Bar"); | ||
} | ||
} | ||
import baz.Foo; | ||
import baz.Bar; | ||
proc main() { | ||
Foo.main(); | ||
Bar.main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* | ||
multiline comments | ||
or block comments | ||
*/ | ||
writeln("Hello, world!"); // 1-line comments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
writeln(1 + 2: real); // 3.0 | ||
writeln(int: string); // int(64) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
writeln(+ scan(1..10)); // 1 3 6 10 15 21 28 36 45 55 | ||
writeln("value, index: ", minloc reduce zip([3, 2, 1], 0..2)); // value, index: (1, 2) | ||
writeln("value, index: ", maxloc reduce zip([4, 5, 6], 0..2)); // value, index: (6, 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
config param foo = 121; | ||
config const bar = 121; | ||
config type num = uint; | ||
writeln(foo, bar, num: string); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
const foo: int = 12; | ||
const bar = 12; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
param foo: int = 12; | ||
param bar = 12; | ||
type num = int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
param a: bool = true; | ||
param b: uint = 1919; | ||
param c: real = 8.10; | ||
param d: imag = 364i; | ||
param e: string = 'ABC' + "DEF"; | ||
param f: Gibier = Gibier.Rabbit; | ||
enum Gibier {Deer, Boar, Rabbit}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
var foo: int = 12; | ||
var bar: int; | ||
foo = 889464; | ||
var a = "golden axe."; | ||
var b = "silver axe."; | ||
a <=> b; | ||
writeln(a, b, foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
while true do break; | ||
for 1..100 do continue; | ||
label outside for i in 1..10 do for j in 1..10 do break outside; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
for i in 1..100 do writeln(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const age = 18; | ||
if age < 18 then { | ||
writeln("Adults Only"); | ||
} else { | ||
writeln("Yeah, Right"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
var foo = 12; | ||
writeln(foo); | ||
} | ||
var foo = 13; | ||
writeln(foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
select "cat" { | ||
when "cat" do writeln("meow"); | ||
when "dog" do writeln("bowwow"); | ||
otherwise writeln("gobblegobble"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var i = 1; | ||
while i < 1024 do i *= 2; | ||
do i >>= 1; while i >= 1; | ||
writeln(i); // 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
proc foo(x: int = 0, y: int = 0): int return x + y; | ||
writeln(foo(x = 1, y = 2)); // 3 | ||
writeln(foo(y = 2, x = 1)); // 3 | ||
writeln(foo(1)); // 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
proc fact(param n: int) param: int where n >= 1 return n * fact(n-1); | ||
proc fact(param n: int) param: int where n == 0 return 1; | ||
if fact(8) != 5040 then compilerError("fact(7) == 5040"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
proc foo(x, y) return x + y; | ||
writeln(foo(1, 2i)); // 1 + 2i | ||
writeln(foo(2i, 3)); // 3 + 2i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
inline proc foo(x: int): int return 2 * x; | ||
export proc bar(x: int): int return 2 * x; | ||
writeln(foo(100)); // 200 | ||
writeln(bar(300)); // 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
proc intents(inout x: int, in y: int, out z: int, ref v: int): void { | ||
x += y; | ||
z += y; | ||
v += y; | ||
} | ||
var a: int = 1; | ||
var b: int = 2; | ||
var c: int = 3; | ||
var d: int = 4; | ||
intents(a, b, c, d); | ||
writeln(a, b, c, d); // 3226 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
iter iterator(): string { | ||
yield "EMURATED"; | ||
yield "EMURATED"; | ||
yield "EMURATED"; | ||
} | ||
iter int.these() const ref: int { | ||
for i in 1..this do yield i; | ||
} | ||
var repetition: int = 10; | ||
for i in iterator() do writeln(i); | ||
for i in repetition do writeln(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
proc call(f, x: int, y: int): int return f(x, y); | ||
const add = lambda(x: int, y: int) return x + y;; | ||
writeln(call(add: func(int, int, int), 36, 514)); // 550 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
var tuple = (0, 0, 0, 0, 0, 0, 0, 0, 0); | ||
proc A(i: int) ref: int return tuple(i); | ||
coforall i in tuple.indices do A(i) = i; | ||
writeln(tuple); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
proc foo return 100110; | ||
writeln(foo); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
proc factorial(num: int): int { | ||
proc tc(n, accum: int): int { | ||
if n == 0 then return accum; | ||
return tc(n - 1, n * accum); | ||
} | ||
return tc(num, 1); | ||
} | ||
writeln(factorial(10)); // 3628800 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
operator *(text: string, num: int) return + reduce (for 1..num do text); | ||
writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit" * 10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
proc tuplet(param dim: int, type eltType) type return dim * eltType; | ||
const septet: tuplet(7, int) = (114, 514, 1919, 810, 364, 889, 464); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
proc foo(x: int, y: int): int { | ||
return x + y; | ||
} | ||
writeln(foo(1, 2)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
proc foo(x: [?dom] ?el) return (dom, el: string); | ||
proc bar(x) return (x.domain, x.eltType: string); | ||
writeln(foo([1, 2, 3, 4, 5, 6, 7, 8])); // ({0..7}, int(64)) | ||
writeln(bar([1, 2, 3, 4, 5, 6, 7, 8])); // ({0..7}, int(64)) | ||
writeln(foo(["one" => 1, "two" => 2])); // ({one, two}, int(64)) | ||
writeln(bar(["one" => 1, "two" => 2])); // ({one, two}, int(64)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require "sched.h"; | ||
extern proc sched_getcpu(): int; | ||
writeln("CPU:", sched_getcpu()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
int sched_getcpu(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
proc foo(message: string) throws { | ||
defer writeln("See you"); | ||
throw new Error(message); | ||
} | ||
try { | ||
foo("Hello,"); | ||
foo("world!"); | ||
} catch e { | ||
writeln(e); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
proc sum(x: int ...): int return + reduce(x); | ||
writeln(sum(1, 2, 3) + sum((...(100, 200)))); // 306 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
proc whichType(x: ?xt): string where xt == real return "x is real"; | ||
proc whichType(x: ?xt): string where xt == imag return "x is imag"; | ||
proc whichType(x: ?xt): string return "x is neither real nor imag"; | ||
writeln(whichType(114.514)); | ||
writeln(whichType(364364i)); | ||
writeln(whichType(1919810)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
record User { | ||
var name: string; | ||
} | ||
proc User.name ref { | ||
writeln(".name"); | ||
return this.name; | ||
} | ||
var user: User; | ||
user.name = "Jane"; | ||
writeln(user.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Sub { | ||
const x: real = 0; | ||
const y: real = 0; | ||
proc deinit() { | ||
writeln("deleted"); | ||
} | ||
} | ||
const sub = new Sub(x = 1, y = 2); | ||
writeln("x, y: ", (sub.x, sub.y)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class Duck { | ||
proc quack() return "quack!"; | ||
} | ||
class Kamo { | ||
proc quack() return "quack!"; | ||
} | ||
proc voice(x) return x.quack(); | ||
writeln(voice(new Duck())); // quack! | ||
writeln(voice(new Kamo())); // quack! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
record Stack { | ||
type eltType; | ||
param size: int; | ||
} | ||
var a: Stack(eltType = uint, size = 12); | ||
var b: Stack(eltType = real, size = 24); | ||
writeln("a is ", a.type: string); // a is Stack(uint(64), 12) | ||
writeln("b is ", b.type: string); // b is Stack(real(64), 24) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Foo { | ||
proc foo() return "foo!"; | ||
} | ||
class Bar: Foo { | ||
override proc foo() return super.foo() + "bar!"; | ||
} | ||
const foo = new Foo(); | ||
const bar = new Bar(); | ||
writeln(foo.foo()); // foo! | ||
writeln(bar.foo()); // foo!bar! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Add { | ||
const x: real; | ||
const y: real; | ||
proc init(x, y) { | ||
this.x = x; | ||
this.y = y; | ||
} | ||
} | ||
const add = new Add(x = 1, y = 2); | ||
writeln("x, y: ", (add.x, add.y)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
record User { | ||
var name: string; | ||
proc set(name) { | ||
this.name = name; | ||
} | ||
} | ||
var user: User; | ||
user.set("Alicia"); | ||
writeln(user.name); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Num { | ||
var r: real; | ||
var i: imag; | ||
} | ||
var num: Num = new Num(); | ||
num.r = 816.07; | ||
num.i = 14.22i; | ||
writeln(num.r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
record Num { | ||
var r: real; | ||
var i: imag; | ||
} | ||
var num: Num; | ||
num.r = 816.07; | ||
num.i = 14.22i; | ||
writeln(num.r); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
union Num { | ||
var r: real; | ||
var i: imag; | ||
} | ||
var num: Num; | ||
num.r = 816.07; | ||
num.i = 14.22i; | ||
writeln(num.i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Hello { | ||
proc deinit() { | ||
writeln("See you"); | ||
} | ||
} | ||
var hello: owned Hello = new owned Hello(); | ||
var hallo: borrowed Hello = hello.borrow(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Hello { | ||
proc deinit() { | ||
writeln("See you"); | ||
} | ||
} | ||
var hello = new shared Hello(); | ||
var hallo = new unmanaged Hello(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Add { | ||
proc this(a: int, b: int): int return a + b; | ||
} | ||
const add = new Add(); | ||
writeln(add(123, 45)); // 168 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const rectangular = [1, 2, 3, 4, 5, 6, 7, 8]; | ||
const associative = [1 => "one", 2 => "two"]; | ||
writeln(rectangular, rectangular.domain); // 1 2 3 4 5 6 7 8{0..7} | ||
writeln(associative, associative.domain); // one two{1, 2} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
writeln(10..30 by -7); // 30 23 16 | ||
writeln(10..30 by -7 align 13); // 27 20 13 | ||
writeln(10..30 by -7 align 13 # 2); // 27 20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const rectangular: domain = {0..10, -1..2}; | ||
const associative: domain = {"foo", "bar"}; | ||
writeln(rectangular.rank); | ||
writeln(rectangular.dims()); | ||
writeln(rectangular.idxType: string); // int(64) | ||
writeln(associative.idxType: string); // string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
for i in 1..100 do writeln(i); | ||
forall i in 1..100 do writeln(i); | ||
coforall i in 1..100 do writeln(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
for xyz in {1..10, 1..10, 1..10} do writeln(xyz); | ||
for boy in {"Tom", "Ken", "Bob"} do writeln(boy); |
Oops, something went wrong.