Browse Source

update all the examples

Getty Ritter 1 year ago
parent
commit
36af76bad7

+ 1 - 1
examples/aquan.matzo

@@ -10,4 +10,4 @@ vowel := ("a" | "e" | "i" | "o" | "u") (4: "" | "'");
 syll := 4: cons vowel | vowel;
 
 (* And finally, here's an output statement *)
-puts syll rep.<1..6, syll>;
+puts syll rep[1..6, syll];

+ 1 - 1
examples/auran.matzo

@@ -1,4 +1,4 @@
-word := start (rep.<1..4,syll>) end;
+word := start (rep[1..4, syll]) end;
 syll := vowel cons;
 start := 3: cons | 2: '';
 end := 3: vowel | vowel 's'| vowel 'n';

+ 1 - 1
examples/druidic.matzo

@@ -1,5 +1,5 @@
 (* Druidic *)
-word := init (rep.<1|2,syll>) end;
+word := init (rep[1|2, syll]) end;
 init := 3: vowel | 2: '';
 syll := cons vowel;
 end ::= a e er ir;

+ 1 - 1
examples/giant.matzo

@@ -1,4 +1,4 @@
-word := begin rep.<1..3,syll> end;
+word := begin rep[1..3, syll] end;
 syll := vowel cons;
 end := vowel ('n'| 'ns' | 's' | '');
 begin := 2: cons | beginvowel;

+ 1 - 1
examples/halfling.matzo

@@ -1,4 +1,4 @@
-word := begin rep.<1..4, syll> end;
+word := begin rep[1..4, syll] end;
 syll := cons vowel;
 end := cons vowel final | cons "é" final | cons "a" final | "r" | "n";
 

+ 8 - 11
examples/halfling_ipa.matzo

@@ -1,18 +1,15 @@
 (* these should probably be part of the stdlib eventually *)
-tuple-map := {func => {tup =>
-  tuple-fold.<{xs => {x => concat.<xs, <func.x>>}}, <>, tup>
-}};
-flatten := {t => tuple-fold.<{ x => { xs => x xs } }, "", t>};
+flatten := {[t] => tuple/fold[{ [x, xs] => x xs }, "", t]};
 
-word := {w => flatten.(tuple-map.orthography.w)};
-wd := concat.<begin, middle, end>;
-middle := syll | concat.<syll, syll> | concat.<syll, syll, syll> | concat.<syll, syll, syll, syll>;
+word := {[w] => flatten[tuple/map[orthography, w]]};
+wd := tuple/concat[<begin, middle, end>];
+middle := syll | tuple/concat[<syll, syll>] | tuple/concat[<syll, syll, syll>] | tuple/concat[<syll, syll, syll, syll>];
 syll := <cons, vowel>;
 end := <cons, vowel, final>
      | 2: <cons, ("eː" | "a"), final>
      | <"r"> | <"n"> ;
 
-orthography :=
+orthography := { [x] => case x in
   { "z"  => "s"
   ; "s"  => "ss"
   ; "dz" => "z"
@@ -33,8 +30,8 @@ orthography :=
   ; "ɾ"  => "r"
   ; "tɾ" => "tr"
   ; "ɾt" => "rt"
-  ; x    => x
-  };
+  ; _    => x
+  } };
 
 begin := <vowel> | <initcons, vowel>;
 
@@ -48,4 +45,4 @@ final := "s" | 6: "";
 
 
 fix wd;
-puts (word.wd) " (pronounced /" (flatten.wd) "/)";
+puts word[wd] " (pronounced /" flatten[wd] "/)";

+ 12 - 12
examples/peano.matzo

@@ -1,15 +1,15 @@
-isZero := { Z => True; <S,_> => False };
-add := { Z     => { y => y }
-       ; <S,x> => { y => add.x.<S,y> } };
-incr := add.<S,Z>;
+isZero := { [Z] => True; [<S,_>] => False };
+add := { [Z]     => { [y] => y }
+       ; [<S,x>] => { [y] => add[x][<S,y>] } };
+incr := add[<S,Z>];
 
 two  := <S,<S,Z>>;
 four := <S,<S,<S,<S,Z>>>>;
 
-if := { True  => { x => { _ => x } }
-      ; False => { _ => { y => y } }
+if := { [True]  => { [x] => { [_] => x } }
+      ; [False] => { [_] => { [y] => y } }
       };
-minusOne := { Z => Z; <S,x> => x };
+minusOne := { [Z] => Z; [<S,x>] => x };
 
 puts "S is " S;
 puts "Z is " Z;
@@ -18,16 +18,16 @@ puts "True is " True;
 puts "False is " False;
 
 puts "Is 0 zero?";
-puts isZero.Z;
+puts isZero[Z];
 
 puts "Is 4 zero?";
-puts isZero.four;
+puts isZero[four];
 
 puts "2 + 4 = ";
-puts add.four.two;
+puts add[four][two];
 
 puts "Is zero zero?";
-puts if.(isZero.Z)."yes"."no";
+puts if[isZero[Z]]["yes"]["no"];
 
 puts "Is 0+1 zero?";
-puts if.(isZero.(incr.Z))."yes"."no";
+puts if[isZero[incr[Z]]]["yes"]["no"];

+ 1 - 1
examples/sylvan.matzo

@@ -1,4 +1,4 @@
-word := syll (rep.<1..4, syll>);
+word := syll rep[1..4, syll];
 
 syll := 2: cons vowel | cons vowel;