2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,3 +1,8 @@
{{Control Structures}} [[Category:Simple]]
This page lists the conditional structures offered by different programming languages.
Common conditional structures are '''if-then-else''' and '''switch'''.
{{Control Structures}}
[[Category:Simple]]
;Task:
List the   ''conditional structures''   offered by a programming language.
Common conditional structures are     '''if-then-else'''     and     '''switch'''.
<br><br>

View file

@ -0,0 +1,73 @@
expression:
opcode,op1,rel,op2
opcode,op1,rel,op2,OR,opcode,op1,rel,op2
opcode,op1,rel,op2,AND,opcode,op1,rel,op2
opcode::=C,CH,CR,CLC,CLI,CLCL, LTR, CP,CE,CD,...
rel::=EQ,NE,LT,LE,GT,GE, (fortran style)
E,L,H,NE,NL,NH (assembler style)
P (plus), M (minus) ,Z (zero) ,O (overflow)
opcode::=CLM,TM
rel::=O (ones),M (mixed) ,Z (zeros)
* IF
IF expression [THEN]
...
ELSEIF expression [THEN]
...
ELSE
...
ENDIF
IF C,R4,EQ,=F'10' THEN if r4=10 then
MVI PG,C'A' pg='A'
ELSEIF C,R4,EQ,=F'11' THEN elseif r4=11 then
MVI PG,C'B' pg='B'
ELSEIF C,R4,EQ,=F'12' THEN elseif r4=12 then
MVI PG,C'C' pg='C'
ELSE else
MV PG,C'?' pg='?'
ENDIF end if
* SELECT
SELECT expressionpart1
WHEN expressionpart2a
...
WHEN expressionpart2b
...
OTHRWISE
...
ENDSEL
* example SELECT type 1
SELECT CLI,HEXAFLAG,EQ select hexaflag=
WHEN X'20' when x'20'
MVI PG,C'<' pg='<'
WHEN X'21' when x'21'
MVI PG,C'!' pg='!'
WHEN X'22' when x'21'
MVI PG,C'>' pg='>'
OTHRWISE otherwise
MVI PG,C'?' pg='?'
ENDSEL end select
* example SELECT type 2
SELECT select
WHEN C,DELTA,LT,0 when delta<0
MVC PG,=C'0 SOL' pg='0 SOL'
WHEN C,DELTA,EQ,0 when delta=0
MVC PG,=C'1 SOL'' pg='0 SOL'
WHEN C,DELTA,GT,0 when delta>0
MVC PG,=C'2 SOL'' pg='0 SOL'
ENDSEL end select
* CASE
CASENTRY R4 select case r4
CASE 1 case 1
LA R5,1 r5=1
CASE 3 case 3
LA R5,2 r5=2
CASE 5 case 5
LA R5,3 r5=1
CASE 7 case 7
LA R5,4 r5=4
ENDCASE end select

View file

@ -0,0 +1,3 @@
if ($expression) {
do_something;
}

View file

@ -0,0 +1,2 @@
# postfix conditional
do_something if $expression;

View file

@ -0,0 +1,6 @@
if ($expression) {
do_something;
}
else {
do_fallback;
}

View file

@ -0,0 +1,9 @@
if ($expression1) {
do_something;
}
elsif ($expression2) {
do_something_different;
}
else {
do_fallback;
}

View file

@ -0,0 +1 @@
$variable = $expression ? $value_for_true : $value_for_false;

View file

@ -0,0 +1 @@
$condition and do_something; # equivalent to $condition ? do_something : $condition

View file

@ -0,0 +1 @@
$condition or do_something; # equivalent to $condition ? $condition : do_something