A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1 @@
|
|||
condition[body]?
|
||||
|
|
@ -0,0 +1 @@
|
|||
$[\true\]?~[false]?
|
||||
|
|
@ -0,0 +1 @@
|
|||
$[%true0~]?~[false]?
|
||||
|
|
@ -0,0 +1 @@
|
|||
t 1 2 ? ! returns 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
t [ 1 ] [ 2 ] if ! returns 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ { [ t ] [ 1 ] } { [ f ] [ 2 ] } } cond ! returns 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
t { { t [ 1 ] } { f [ 2 ] } } case ! returns 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
t [ "1" print ] when ! prints 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
f [ "1" print ] unless ! prints 1
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if: (x < y) then: {
|
||||
"x < y!" println # will only execute this block if x < y
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
if: (x < y) then: {
|
||||
"x < y!" println # will only execute this block if x < y
|
||||
} else: {
|
||||
"x not < y!" println
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
x < y if_true: {
|
||||
"x < y!" println # will only execute this block if x < y
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
x < y if_false: {
|
||||
"x not < y!" println # will only execute this block if x >= y
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
x < y if_true: {
|
||||
"x < y!" println
|
||||
} else: {
|
||||
"x >= y!" println
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
x < y if_false: {
|
||||
"x >= y!"
|
||||
} else: {
|
||||
"x < y!" println
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ "x < y!" println } if: (x < y) # analog, but postfix
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ "x not < y!" } unless: (x < y) # same here
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
IF( a > 5 ) WRITE(Messagebox) a ! single line IF
|
||||
|
||||
IF( a >= b ) THEN
|
||||
WRITE(Text=some_string) a, b
|
||||
ELSEIF(some_string > "?") THEN
|
||||
WRITE(ClipBoard) some_string
|
||||
ELSEIF( nonzero ) THEN
|
||||
WRITE(WINdowhandle=nnn) some_string
|
||||
ELSE
|
||||
WRITE(StatusBar) a, b, some_string
|
||||
ENDIF
|
||||
|
|
@ -0,0 +1 @@
|
|||
if a eq 5 then print, "a equals five" [else print, "a is something else"]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
if a eq 5 then begin
|
||||
... some code here ...
|
||||
endif [else begin
|
||||
... some other code here ...
|
||||
endelse]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
case <expression> of
|
||||
(choice-1): <command-1>
|
||||
[(choice-2): <command-2> [...]]
|
||||
[else: <command-else>]
|
||||
endcase
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
switch <expression> of
|
||||
(choice-1): <command-1>
|
||||
[(choice-2): <command-2> [...]]
|
||||
[else: <command-else>]
|
||||
endswitch
|
||||
|
|
@ -0,0 +1 @@
|
|||
on_error label
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
if expr0 then
|
||||
expr1
|
||||
else
|
||||
expr2
|
||||
|
|
@ -0,0 +1 @@
|
|||
expr0(expr1, expr2, expr3)
|
||||
|
|
@ -0,0 +1 @@
|
|||
2(expr1, expr2, expr3)
|
||||
|
|
@ -0,0 +1 @@
|
|||
f(expr1)(g(expr2)(expr3,expr4,expr5))
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
case expr0 of {
|
||||
expr1 : expr2
|
||||
expr3 : expr4
|
||||
default: expr5
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
case x of {
|
||||
f(x) | g(x) : expr2
|
||||
s(x) & t(x) : expr4
|
||||
default: expr5
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
expr1
|
||||
expr2
|
||||
expr3
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{expr1; expr2; expr3}
|
||||
|
|
@ -0,0 +1 @@
|
|||
write({1;2;3;4})
|
||||
|
|
@ -0,0 +1 @@
|
|||
expr1 | expr2 | expr3
|
||||
|
|
@ -0,0 +1 @@
|
|||
expr1 & expr2 & expr3
|
||||
|
|
@ -0,0 +1 @@
|
|||
(expr1, expr2, expr3)
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
[short form]
|
||||
if N is 1, say "one.";
|
||||
otherwise say "not one.";
|
||||
|
||||
[block form]
|
||||
if N is 1:
|
||||
say "one.";
|
||||
otherwise if N is 2:
|
||||
say "two.";
|
||||
otherwise:
|
||||
say "not one or two.";
|
||||
|
||||
[short and long forms can be negated with "unless"]
|
||||
unless N is 1, say "not one."
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
if N is:
|
||||
-- 1: say "one.";
|
||||
-- 2: say "two.";
|
||||
-- otherwise: say "not one or two.";
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
say "[if N is 1]one[otherwise if N is 2]two[otherwise]three[end if].";
|
||||
say "[unless N is odd]even.[end if]";
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[a different color every time]
|
||||
say "[one of]red[or]blue[or]green[at random].";
|
||||
|
||||
["one" the first time it's printed, "two" the second time, then "three or more" subsequently]
|
||||
say "[one of]one[or]two[or]three or more[stopping]";
|
||||
|
||||
[only appears once]
|
||||
say "[first time]Hello world![only]";
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
Number Factory is a room.
|
||||
|
||||
Number handling is a number based rulebook with default success.
|
||||
|
||||
Number handling for 1: say "one."
|
||||
Number handling for 2: say "two."
|
||||
Number handling for an even number (called N): say "[N in words] (which is even)."
|
||||
Last number handling rule: say "other."
|
||||
|
||||
When play begins:
|
||||
follow the number handling rules for 2;
|
||||
follow the number handling rules for 4;
|
||||
follow the number handling rules for 5.
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
t : " true" ,t
|
||||
f : " false" ,t
|
||||
true if t
|
||||
false ifnot f
|
||||
true ifelse t f
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
onetwo : drop " Neither one nor two" ,t # default declared first
|
||||
onetwo : dup 2 = then " Two" ,t
|
||||
onetwo : dup 1 = then " One" ,t
|
||||
|
|
@ -0,0 +1 @@
|
|||
dup 0 = || ,t # avoid printing a null string
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
+ n : INTEGER;
|
||||
|
||||
n := 3;
|
||||
|
||||
(n = 2).if {
|
||||
IO.put_string "n is 2\n";
|
||||
}.elseif {n = 3} then {
|
||||
IO.put_string "n is 3\n";
|
||||
}.elseif {n = 4} then {
|
||||
IO.put_string "n is 4\n";
|
||||
} else {
|
||||
IO.put_string "n is none of the above\n";
|
||||
};
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
(n = 2).if_true { "n is 2\n".print; };
|
||||
(n = 2).if_false { "n is not 2\n".print; };
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
+ n : INTEGER;
|
||||
|
||||
n := 3;
|
||||
n
|
||||
.when 2 then {
|
||||
"n is 2\n".print;
|
||||
}
|
||||
.when 3 then {
|
||||
"n is 3\n".print;
|
||||
}
|
||||
.when 4 then {
|
||||
"n is 4\n".print;
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if :x < 0 [make "x 0 - :x]
|
||||
|
||||
ifelse emptyp :list [print [empty]] [print :list]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
to vowel? :letter
|
||||
output case :letter [ [[a e i o u] "true] [else "false] ]
|
||||
end
|
||||
show vowel? "e
|
||||
show vowel? "x
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
true
|
||||
false
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
to mytest :arg1 :arg2
|
||||
test :arg1 = :arg2
|
||||
iftrue [print [Arguments are equal]]
|
||||
iffalse [print [Arguments are not equal]]
|
||||
end
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
if x == 1 then
|
||||
(
|
||||
print "one"
|
||||
)
|
||||
else if x == 2 then
|
||||
(
|
||||
print "two"
|
||||
)
|
||||
else
|
||||
(
|
||||
print "Neither one or two"
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
case x of
|
||||
(
|
||||
1: (print "one")
|
||||
2: (print "two")
|
||||
default: (print "Neither one or two")
|
||||
)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
case of
|
||||
(
|
||||
(x == 1): (print "one")
|
||||
(x == 2): (print "two")
|
||||
default: (print "Neither one or two")
|
||||
)
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
INT x;
|
||||
x:=0;
|
||||
IF x = 1 THEN
|
||||
! Do something
|
||||
ELSE
|
||||
! Do something else
|
||||
ENDIF;
|
||||
|
|
@ -0,0 +1 @@
|
|||
IF A list-of-MUMPS-commands
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
IF T DO SUBROUTINE
|
||||
ELSE DO SOMETHING
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
IF T DO SUBROUTINE IF 1
|
||||
ELSE DO SOMETHING
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
IF T DO
|
||||
. DO SUBROUTINE
|
||||
ELSE DO SOMETHING
|
||||
|
|
@ -0,0 +1 @@
|
|||
WRITE $SELECT(1=2:"Unequal",1=3:"More unequal",1:"Who cares?")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
SET:(1=1) SKY="Blue"
|
||||
GOTO:ReallyGo LABEL
|
||||
QUIT:LoopDone
|
||||
WRITE:NotLastInSet ","
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# make -f do.mk C=mycond if
|
||||
C=0
|
||||
|
||||
if:
|
||||
-@expr $(C) >/dev/null && make -f do.mk true; exit 0
|
||||
-@expr $(C) >/dev/null || make -f do.mk false; exit 0
|
||||
|
||||
true:
|
||||
@echo "was true."
|
||||
|
||||
false:
|
||||
@echo "was false."
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
make -f do.mk if C=0
|
||||
> was false.
|
||||
|
||||
make -f do.mk if C=1
|
||||
> was true.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
C=0
|
||||
|
||||
if: true false
|
||||
|
||||
true:
|
||||
@expr $(C) >/dev/null && exit 0 || exit 1
|
||||
@echo "was true."
|
||||
|
||||
false:
|
||||
@expr $(C) >/dev/null && exit 1 || exit 0
|
||||
@echo "was false."
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
|make -f do.mk -s -k C=1
|
||||
was true.
|
||||
*** Error code 1
|
||||
|make -f do.mk -s -k C=0
|
||||
*** Error code 1
|
||||
was false.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
A=
|
||||
B=
|
||||
|
||||
ifeq "$(A)" "1"
|
||||
B=true
|
||||
else
|
||||
B=false
|
||||
endif
|
||||
|
||||
do:
|
||||
@echo $(A) .. $(B)
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
|gmake -f if.mk A=1
|
||||
1 .. true
|
||||
|gmake -f if.mk A=0
|
||||
0 .. false
|
||||
|
|
@ -0,0 +1 @@
|
|||
if test1 then (...) elseif test2 then (...) else (...);
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
if conditionA:
|
||||
% do something
|
||||
elseif conditionB:
|
||||
% do something
|
||||
% more elseif, if needed...
|
||||
else:
|
||||
% do this
|
||||
fi;
|
||||
|
|
@ -0,0 +1 @@
|
|||
b := if a > 5: 3 + else: 2 - fi c;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
IF i = 1 THEN
|
||||
InOut.WriteString('One')
|
||||
ELSIF i = 2 THEN
|
||||
InOut.WriteString('Two')
|
||||
ELSIF i = 3 THEN
|
||||
InOut.WriteString('Three')
|
||||
ELSE
|
||||
InOut.WriteString('Other')
|
||||
END;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
CASE i OF
|
||||
1 : InOut.WriteString('One')
|
||||
| 2 : InOut.WriteString('Two')
|
||||
| 3 : InOut.WriteString('Three')
|
||||
ELSE
|
||||
InOut.WriteString('Other')
|
||||
END
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
IF Foo = TRUE THEN
|
||||
Bar();
|
||||
ELSE
|
||||
Baz();
|
||||
END;
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
IF Foo = "foo" THEN
|
||||
Bar();
|
||||
ELSIF Foo = "bar" THEN
|
||||
Baz();
|
||||
ELSIF Foo = "foobar" THEN
|
||||
Quux();
|
||||
ELSE
|
||||
Zeepf();
|
||||
END;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
CASE Foo OF
|
||||
| 1 => IO.Put("One\n");
|
||||
| 2 => IO.Put("Two\n");
|
||||
| 3 => IO.Put("Three\n");
|
||||
ELSE
|
||||
IO.Put("Something\n");
|
||||
END;
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
TYPECASE ref OF
|
||||
| NULL => IO.Put("Null\n");
|
||||
| CHAR => IO.Put("Char\n");
|
||||
| INTEGER => IO.Put("Integer\n");
|
||||
ELSE
|
||||
IO.Put("Something\n");
|
||||
END;
|
||||
Loading…
Add table
Add a link
Reference in a new issue