rename funct to proc

This commit is contained in:
prod2 2022-02-09 06:58:51 +01:00
parent 3a9e23b82e
commit f79f4e47ba
10 changed files with 56 additions and 56 deletions

View File

@ -1,4 +1,4 @@
var fact = funct(n) var fact = proc(n)
if (n > 0) if (n > 0)
:result = n * fact(n-1) :result = n * fact(n-1)
else else

View File

@ -1,4 +1,4 @@
var fib = funct(n) var fib = proc(n)
if (n < 2) :result = 1 if (n < 2) :result = 1
else :result = fib(n-1) + fib(n-2) else :result = fib(n-1) + fib(n-2)
; ;

View File

@ -1,4 +1,4 @@
var main = funct() { var main = proc() {
// source // source
var src = ">++++++++++[<++++++++++>-]<->>>>>+++[>+++>+++<<-]<<<<+<[>[>+>+<<-]>>[-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]>>>>>>[[-]<++++++++++<->>]<-[>+>+<<-]>[<+>-]+>[[-]<->]<<<<<<<<<->>]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>>>++++++++[>>++++++<<-]>[<++++++++[>++++++<-]>.<++++++++[>------<-]>[<<+>>-]]>.<<++++++++[>>------<<-]<[->>+<<]<++++++++[<++++>-]<.>+++++++[>+++++++++<-]>+++.<+++++[>+++++++++<-]>.+++++..--------.-------.++++++++++++++>>[>>>+>+<<<<-]>>>>[-<<<<+>>>>]>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<<[>>>+>+<<<<-]>>>>[-<<<<+>>>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+<<[-]]>[>+<[-]]++>>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<+<[[-]>-<]>[<<<<<<<.>>>>>>>[-]]<<<<<<<<<.>>----.---------.<<.>>----.+++..+++++++++++++.[-]<<[-]]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>++++++++[<++++>-]<.>++++++++++[>+++++++++++<-]>+.-.<<.>>++++++.------------.---.<<.>++++++[>+++<-]>.<++++++[>----<-]>++.+++++++++++..[-]<<[-]++++++++++.[-]]<[>+>+<<-]>>[-<<+>>]+++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++. >+++++++++[>+++++++++<-]>+++.+++++++++++++.++++++++++.------.<++++++++[>>++++<<-]>>.<++++++++++.-.---------.>.<-.+++++++++++.++++++++.---------.>.<-------------.+++++++++++++.----------.>.<++++++++++++.---------------.<+++[>++++++<-]>..>.<----------.+++++++++++.>.<<+++[>------<-]>-.+++++++++++++++++.---.++++++.-------.----------.[-]>[-]<<<.[-]]<[>+>+<<-]>>[-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.[-]<[-]>]<+<]"; var src = ">++++++++++[<++++++++++>-]<->>>>>+++[>+++>+++<<-]<<<<+<[>[>+>+<<-]>>[-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]>>>>>>[[-]<++++++++++<->>]<-[>+>+<<-]>[<+>-]+>[[-]<->]<<<<<<<<<->>]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>>>++++++++[>>++++++<<-]>[<++++++++[>++++++<-]>.<++++++++[>------<-]>[<<+>>-]]>.<<++++++++[>>------<<-]<[->>+<<]<++++++++[<++++>-]<.>+++++++[>+++++++++<-]>+++.<+++++[>+++++++++<-]>.+++++..--------.-------.++++++++++++++>>[>>>+>+<<<<-]>>>>[-<<<<+>>>>]>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<<[>>>+>+<<<<-]>>>>[-<<<<+>>>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+<<[-]]>[>+<[-]]++>>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<+<[[-]>-<]>[<<<<<<<.>>>>>>>[-]]<<<<<<<<<.>>----.---------.<<.>>----.+++..+++++++++++++.[-]<<[-]]<[>+>+<<-]>>[-<<+>>]+>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<<[>>+>+<<<-]>>>[-<<<+>>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[>+<[-]]<[>>+<<[-]]>>[<<+>>[-]]<<[[-]>++++++++[<++++>-]<.>++++++++++[>+++++++++++<-]>+.-.<<.>>++++++.------------.---.<<.>++++++[>+++<-]>.<++++++[>----<-]>++.+++++++++++..[-]<<[-]++++++++++.[-]]<[>+>+<<-]>>[-<<+>>]+++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++. >+++++++++[>+++++++++<-]>+++.+++++++++++++.++++++++++.------.<++++++++[>>++++<<-]>>.<++++++++++.-.---------.>.<-.+++++++++++.++++++++.---------.>.<-------------.+++++++++++++.----------.>.<++++++++++++.---------------.<+++[>++++++<-]>..>.<----------.+++++++++++.>.<<+++[>------<-]>-.+++++++++++++++++.---.++++++.-------.----------.[-]>[-]<<<.[-]]<[>+>+<<-]>>[-<<+>>]++++>+<[-<->]<[[-]>>-<<]>>[[-]<<+>>]<<[[-]++++++++++.[-]<[-]>]<+<]";
var pos = 0; var pos = 0;

View File

@ -145,7 +145,7 @@ const keywords = {
"else": tkElse, "else": tkElse,
"false": tkFalse, "false": tkFalse,
"for": tkFor, "for": tkFor,
"funct": tkFunct, "proc": tkFunct,
# here's a language that uses funct... still waiting for the day when a good de-funct joke comes to my mind that I can abuse # here's a language that uses funct... still waiting for the day when a good de-funct joke comes to my mind that I can abuse
"goto": tkGoto, "goto": tkGoto,
"if": tkIf, "if": tkIf,

View File

@ -44,7 +44,7 @@
//expect:5.0 //expect:5.0
var f = funct() { @result var f = proc() { @result
var y = 1; var y = 1;
var z = 3; var z = 3;
var p = 1; var p = 1;
@ -59,7 +59,7 @@ print (f());
//expect:15.0 //expect:15.0
f = funct(m, n) f = proc(m, n)
m + n m + n
; ;
@ -68,7 +68,7 @@ print (f(f(5, 5), 5));
//expect:10.0 //expect:10.0
var g = funct() var g = proc()
{@a {@a
:a = { @b :a = { @b
:b = { @c :b = { @c
@ -82,7 +82,7 @@ print (g());
//expect:9.0 //expect:9.0
var h = funct() var h = proc()
{@a {@a
:a = { @b :a = { @b
:b = { @c :b = { @c

View File

@ -1,21 +1,21 @@
// cascade // cascade
var f1 = funct() { var f1 = proc() {
var x = 1; var x = 1;
var y = 5; var y = 5;
funct() { proc() {
var z = 8; var z = 8;
print (x); print (x);
x = x + 1; x = x + 1;
funct() { proc() {
print (x); print (x);
x = x + 1; x = x + 1;
funct() { proc() {
print (x); print (x);
print (y); print (y);
print (z); print (z);
x = x + 1; x = x + 1;
funct() { proc() {
print (x); print (x);
x = x + 1; x = x + 1;
} }
@ -33,11 +33,11 @@ f1()()()()();
// capturing closures in lists: // capturing closures in lists:
var f = funct() { var f = proc() {
var y = 5; var y = 5;
var x = @[ var x = @[
funct() print (y), proc() print (y),
funct() y = y + 1 proc() y = y + 1
]; ];
x x
}; };
@ -52,12 +52,12 @@ inst[0]();
// multiple different labels // multiple different labels
var f2 = funct() { @result var f2 = proc() { @result
var x = { @a @b var x = { @a @b
// this captures the internal value, not whatever it returns is assigned to // this captures the internal value, not whatever it returns is assigned to
:result = @{ :result = @{
get = funct() print (:a), get = proc() print (:a),
["set"] = funct(n) :b = n, ["set"] = proc(n) :b = n,
}; };
}; };
x = 5; x = 5;
@ -72,8 +72,8 @@ inst2["get"]();
// capturing args // capturing args
var argcap = funct(n) var argcap = proc(n)
funct() print (n) proc() print (n)
; ;
//expect:8.1 //expect:8.1
@ -82,12 +82,12 @@ argcap(8.1)();
// oop: constructors, getters, setters // oop: constructors, getters, setters
var newAnimal = funct(species, color) { @result var newAnimal = proc(species, color) { @result
var species = species; // copy it so that it's mutable, if args ever get immutable var species = species; // copy it so that it's mutable, if args ever get immutable
var animal = @{ var animal = @{
["getSpecies"] = funct() species, ["getSpecies"] = proc() species,
["setSpecies"] = funct(newSpecies) species = newSpecies, ["setSpecies"] = proc(newSpecies) species = newSpecies,
["getColor"] = funct() color, // this captures an argument directly ["getColor"] = proc() color, // this captures an argument directly
}; };
:result = animal; :result = animal;
}; };
@ -116,8 +116,8 @@ print (turtle["getSpecies"]());
// 1: // 1:
var makeClosure = funct(value) { @result var makeClosure = proc(value) { @result
var closure = funct() { var closure = proc() {
print (value); print (value);
}; };
:result = closure; :result = closure;
@ -132,10 +132,10 @@ bagel();
// 2: (multi level closures) // 2: (multi level closures)
var outer = funct() { @result var outer = proc() { @result
var x = "value"; var x = "value";
var middle = funct() { @result var middle = proc() { @result
var inner = funct() { var inner = proc() {
print (x); print (x);
}; };
@ -157,20 +157,20 @@ in();
// 3: (mixed multi level closures) // 3: (mixed multi level closures)
outer = funct() { @result outer = proc() { @result
var a = 1; var a = 1;
var b = 2; var b = 2;
var result; var result;
var middle = funct() { var middle = proc() {
var c = 3; var c = 3;
var d = 4; var d = 4;
var inner = funct() { var inner = proc() {
print (a + c + b + d); print (a + c + b + d);
}; };
result = inner; result = inner;
}; };
middle(); middle();
:result = funct() result; :result = proc() result;
}; };
//expect:10.0 //expect:10.0
@ -178,9 +178,9 @@ outer()()();
// 4: manipulation of vals from closures // 4: manipulation of vals from closures
outer = funct() { outer = proc() {
var x = "before"; var x = "before";
var inner = funct() { var inner = proc() {
x = "assigned"; x = "assigned";
}; };
inner(); inner();
@ -195,11 +195,11 @@ outer();
var globalSet; var globalSet;
var globalGet; var globalGet;
var main5 = funct() { var main5 = proc() {
var a = "initial"; var a = "initial";
var set = funct() { a = "updated"; }; var set = proc() { a = "updated"; };
var get = funct() { print (a); }; var get = proc() { print (a); };
globalSet = set; globalSet = set;
globalGet = get; globalGet = get;
@ -216,15 +216,15 @@ globalGet();
{ {
var a = 1; var a = 1;
var f = funct() { var f = proc() {
print (a); print (a);
}; };
var b = 2; var b = 2;
var g = funct() { var g = proc() {
print (b); print (b);
}; };
var c = 3; var c = 3;
var h = funct() { var h = proc() {
print (c); print (c);
}; };
@ -238,17 +238,17 @@ globalGet();
// bonus: the last one with a list twist // bonus: the last one with a list twist
var bonus = funct() { @result var bonus = proc() { @result
var a = 1; var a = 1;
var f = funct() { var f = proc() {
print (a); print (a);
}; };
var b = 2; var b = 2;
var g = funct() { var g = proc() {
print (b); print (b);
}; };
var c = 3; var c = 3;
var h = funct() { var h = proc() {
print (c); print (c);
}; };

View File

@ -1,6 +1,6 @@
// a test about collections, WIP // a test about collections, WIP
var returnlist = funct() var returnlist = proc()
@[1, 2, 3, 4] @[1, 2, 3, 4]
; ;

View File

@ -60,7 +60,7 @@ if (@[]) print ("6");
if (@["hi"]) print ("7"); if (@["hi"]) print ("7");
if (@{}) print ("8"); if (@{}) print ("8");
if (@{["hi"] = 5}) print ("9"); if (@{["hi"] = 5}) print ("9");
if (funct(n) print (n)) print ("10"); if (proc(n) print (n)) print ("10");
//expect:1 //expect:1
//expect:2 //expect:2

View File

@ -15,7 +15,7 @@ print (-((3 + 2) * 2) + 1);
// calls and indexes // calls and indexes
var returnlist = funct() { @result var returnlist = proc() { @result
:result = @[]; :result = @[];
:result[0] = 4; :result[0] = 4;
:result[1] = 6; :result[1] = 6;
@ -27,7 +27,7 @@ var returnlist = funct() { @result
print (returnlist()[2]); print (returnlist()[2]);
// priority over unary // priority over unary
var truesayer = funct() var truesayer = proc()
true true
; ;

View File

@ -1,13 +1,13 @@
// testing syntactic sugars // testing syntactic sugars
// :: piping function call // :: piping procion call
var double = funct(num) num * 2; var double = proc(num) num * 2;
var four = 2 :: double(); var four = 2 :: double();
var multiply = funct(num, factor) num * factor; var multiply = proc(num, factor) num * factor;
var six = 2 :: multiply(3); var six = 2 :: multiply(3);
@ -56,7 +56,7 @@ print(mix.ident, mix["ident2"], mix[3], mix.ident4);
// -> method call syntax // -> method call syntax
var class = @{ var class = @{
method = funct(self) print ("i was called") method = proc(self) print ("i was called")
}; };
// no args needed then no parentheses needed // no args needed then no parentheses needed
@ -65,7 +65,7 @@ class->method;
var multiplier = @{ var multiplier = @{
multiple = 5, multiple = 5,
do = funct(self, arg) self.multiple * arg, do = proc(self, arg) self.multiple * arg,
}; };
multiplier->do(7) :: print; multiplier->do(7) :: print;
@ -74,7 +74,7 @@ multiplier->do(7) :: print;
// -> method call syntax with :: - check for precedence // -> method call syntax with :: - check for precedence
var returner = @{ var returner = @{
method = funct(self) funct(n) n * 2 method = proc(self) proc(n) n * 2
}; };
1.7 :: returner->method :: print; 1.7 :: returner->method :: print;