-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
46 changed files
with
868 additions
and
894 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
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 |
---|---|---|
@@ -1,35 +1,35 @@ | ||
(type v2 {:z float :y float}) | ||
(type i2 {:x int :y int}) | ||
(type i1 {:x int}) | ||
(type v1 {:z float}) | ||
(type v3 {:x float :y float :z float}) | ||
(type i3 {:w int :y int :z int}) | ||
(type v4 {:x float :y float :z float :w float}) | ||
(type mixed4 {:x float :y float :z float :k int}) | ||
(type trailv2 {:a int :b int :c float :d float}) | ||
(type f2s {:fx f32 :fy f32}) | ||
(type f3s {:fx f32 :fy f32 :fz f32}) | ||
type v2 = {z : float, y : float} | ||
type i2 = {x : int, y : int} | ||
type i1 = {x : int} | ||
type v1 = {z : float} | ||
type v3 = {x : float, y : float, z : float} | ||
type i3 = {w : int, y : int, z : int} | ||
type v4 = {x : float, y : float, z : float, w : float} | ||
type mixed4 = {x : float, y : float, z : float, k : int} | ||
type trailv2 = {a : int, b : int, c : float, d : float} | ||
type f2s = {fx : f32, fy : f32} | ||
type f3s = {fx : f32, fy : f32, fz : f32} | ||
|
||
(external subv2 (fun v2 v2)) | ||
(external subi2 (fun i2 i2)) | ||
(external subv1 (fun v1 v1)) | ||
(external subi1 (fun i1 i1)) | ||
(external subv3 (fun v3 v3)) | ||
(external subi3 (fun i3 i3)) | ||
(external subv4 (fun v4 v4)) | ||
(external submixed4 (fun mixed4 mixed4)) | ||
(external subtrailv2 (fun trailv2 trailv2)) | ||
(external subf2s (fun f2s f2s)) | ||
(external subf3s (fun f3s f3s)) | ||
external subv2 : (v2) -> v2 | ||
external subi2 : (i2) -> i2 | ||
external subv1 : (v1) -> v1 | ||
external subi1 : (i1) -> i1 | ||
external subv3 : (v3) -> v3 | ||
external subi3 : (i3) -> i3 | ||
external subv4 : (v4) -> v4 | ||
external submixed4 : (mixed4) -> mixed4 | ||
external subtrailv2 : (trailv2) -> trailv2 | ||
external subf2s : (f2s) -> f2s | ||
external subf3s : (f3s) -> f3s | ||
|
||
(ignore (subv2 {:z 1.0 :y 10.0})) | ||
(ignore (subi2 {:x 1 :y 10 })) | ||
(ignore (subv1 {:z 1.0})) | ||
(ignore (subi1 {:x 1 })) | ||
(ignore (subv3 {:x 1.0 :y 10.0 :z 100.0 })) | ||
(ignore (subi3 {:w 1 :y 10 :z 100 })) | ||
(ignore (subv4 {:x 1.0 :y 10.0 :z 100.0 :w 1000.0})) | ||
(ignore (submixed4 {:x 1.0 :y 10.0 :z 100.0 :k 1 })) | ||
(ignore (subtrailv2 {:a 1 :b 2 :c 1.0 :d 2.0 })) | ||
(ignore (subf2s {:fx 2.0f32 :fy 3.0f32})) | ||
(ignore (subf3s {:fx 2.0f32 :fy 3.0f32 :fz 5.0f32})) | ||
ignore (subv2 ({z = 1.0, y = 10.0})) | ||
ignore (subi2 ({x = 1, y = 10 })) | ||
ignore (subv1 ({z = 1.0})) | ||
ignore (subi1 ({x = 1 })) | ||
ignore (subv3 ({x = 1.0, y = 10.0, z = 100.0 })) | ||
ignore (subi3 ({w = 1, y = 10, z = 100 })) | ||
ignore (subv4 ({x = 1.0, y = 10.0, z = 100.0, w = 1000.0})) | ||
ignore (submixed4 ({x = 1.0, y = 10.0, z = 100.0, k = 1 })) | ||
ignore (subtrailv2 ({a = 1, b = 2, c = 1.0, d = 2.0 })) | ||
ignore (subf2s ({fx = 2.0f32, fy = 3.0f32})) | ||
ignore (subf3s ({fx = 2.0f32, fy = 3.0f32, fz = 5.0f32})) |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
(def nested& [[0 1] [2 3]]) | ||
(print (fmt-str (array/length nested))) | ||
(array/drop-back &nested) | ||
(print (fmt-str (array/length nested))) | ||
(array/drop-back &nested) | ||
(print (fmt-str (array/length nested))) | ||
(array/drop-back &nested) | ||
(print (fmt-str (array/length nested))) | ||
let nested& = [[0, 1], [2, 3]] | ||
print(fmt(Array.length(nested))) | ||
Array.drop_back(&nested) | ||
print(fmt(Array.length(nested))) | ||
Array.drop_back(&nested) | ||
print(fmt(Array.length(nested))) | ||
Array.drop_back(&nested) | ||
print(fmt(Array.length(nested))) |
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 |
---|---|---|
@@ -1,28 +1,27 @@ | ||
(def a& [10 20]) | ||
(def b (copy a)) | ||
let a& = [10, 20] | ||
let b = copy(a) | ||
|
||
(array/push &a !30) | ||
Array.push(&a, !30) | ||
|
||
(print (fmt-str (array/length a))) | ||
(print (fmt-str (array/length b))) | ||
print(fmt(Array.length(a))) | ||
print(fmt(Array.length(b))) | ||
|
||
fun in_fun(): | ||
let a& = [10, 20] | ||
let b = copy(a) | ||
|
||
(defn in-fun () | ||
(def a& [10 20]) | ||
(def b (copy a)) | ||
Array.push(&a, !30) | ||
|
||
(array/push &a !30) | ||
print(fmt(Array.length(a))) | ||
print(fmt(Array.length(b))) | ||
|
||
(print (fmt-str (array/length a))) | ||
(print (fmt-str (array/length b)))) | ||
in_fun() | ||
|
||
(in-fun) | ||
|
||
(def nested& [[0 1] [2 3]]) | ||
(def a [4 5]) | ||
(array/push &nested !(copy a)) | ||
(set & nested.[1] !(copy a)) | ||
(set &nested.[1] !(copy a)) | ||
(array/push &nested ![4 5]) | ||
(set &nested.[1] ![4 5]) | ||
(set &nested.[1] ![4 5]) | ||
let nested& = [[0, 1], [2, 3]] | ||
let a = [4, 5] | ||
Array.push(&nested, !copy(a)) | ||
&nested.[1] <- copy(a) | ||
&nested.[1] <- copy(a) | ||
Array.push(&nested, ![4, 5]) | ||
&nested.[1] <- [4, 5] | ||
&nested.[1] <- [4, 5] |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
(external stdout (raw_ptr u8)) | ||
(external fflush (fun (raw_ptr u8) unit)) | ||
external stdout : raw_ptr(u8) | ||
external fflush : (raw_ptr(u8)) -> unit | ||
|
||
(assert true) | ||
assert(true) | ||
|
||
(print "hmm") | ||
(fflush stdout) -- flush to see it in testing | ||
print("hmm") | ||
fflush(stdout) -- flush to see it in testing | ||
|
||
(assert false) | ||
assert(false) | ||
|
||
(print "lol") | ||
print("lol") |
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 |
---|---|---|
@@ -1,53 +1,63 @@ | ||
(defn true_ () | ||
(print "true") | ||
true) | ||
|
||
(defn false_ () | ||
(print "false") | ||
false) | ||
|
||
(print "test 'and':") | ||
|
||
(if (and (true_) (true_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (and (true_) (false_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (and (false_) (true_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (and (false_) (false_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(print "test 'or':") | ||
|
||
(if (or (true_) (true_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (or (true_) (false_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (or (false_) (true_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (or (false_) (false_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(print "test 'not':") | ||
|
||
(if (not (true_)) | ||
(print "yes") | ||
(print "no")) | ||
|
||
(if (not (false_)) | ||
(print "yes") | ||
(print "no")) | ||
fun true_(): | ||
print("true") | ||
true | ||
|
||
fun false_(): | ||
print("false") | ||
false | ||
|
||
print("test 'and':") | ||
|
||
if true_() and true_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if true_() and false_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if false_() and true_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if false_() and false_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
print ("test 'or':") | ||
|
||
if true_() or true_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if true_() or false_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if false_() or true_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if false_() or false_(): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
print("test 'not':") | ||
|
||
if not(true_()): | ||
print("yes") | ||
else: | ||
print("no") | ||
|
||
if not(false_()): | ||
print("yes") | ||
else: | ||
print("no") |
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 |
---|---|---|
@@ -1 +1 @@ | ||
(ignore (if true "ok" "err")) | ||
ignore(if true: "ok" else: "err") |
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 |
---|---|---|
@@ -1,28 +1,27 @@ | ||
(defn bind (res f) | ||
(match res | ||
((#some r) (f r)) | ||
(#none #none))) | ||
fun bind(res, f): | ||
match res: | ||
Some(r): f(r) | ||
None: None | ||
|
||
(defn use (param thing) | ||
(match param | ||
({bar foo} (bind (bar thing) | ||
-- (foo) must be captured here | ||
(fn (r) (bind (foo r) | ||
(fn (r) (print (fmt-str r)) (#some (copy r))))))))) | ||
fun use(param, thing): | ||
match param: | ||
(bar, foo): bind(bar(thing), fun r: | ||
bind(foo(r), fun r: | ||
print(fmt(r)) | ||
Some(copy(r)))) | ||
|
||
(ignore | ||
(use {(fn (i) (#some (+ i 1))) | ||
(fn (i) (#some (+ i 2)))} | ||
0)) | ||
ignore(use((fun i: Some(i + 1), | ||
fun i: Some(i + 2)), | ||
0)) | ||
|
||
-- This here is just a test to make sure that we can alias normal, | ||
-- monomorphized functions | ||
(defn f (i) | ||
(print (fmt-str "printing " i))) | ||
-- This here is just a test to make sure that we can alias normal, monomorphized | ||
-- functions | ||
fun f(i): | ||
print(fmt("printing ", i)) | ||
|
||
(defn print-poly (to-print) | ||
(match f | ||
(foo (foo to-print)))) | ||
fun print_poly(to_print): | ||
match f: | ||
foo: foo(to_print) | ||
|
||
(print-poly 0) | ||
(print-poly 1.1) | ||
print_poly(0) | ||
print_poly(1.1) |
Oops, something went wrong.