Another update from ingydotnet^djgoku

This commit is contained in:
Ingy döt Net 2015-11-18 06:14:39 +00:00
parent 91df62d461
commit 948b86eafa
7604 changed files with 108452 additions and 22726 deletions

View file

@ -0,0 +1,10 @@
EVALUATE EXPRESSION-1 ALSO EXPRESSION-2
WHEN TRUE ALSO TRUE
DISPLAY 'Both are true.'
WHEN TRUE ALSO FALSE
DISPLAY 'Expression 1 is true.'
WHEN FALSE ALSO TRUE
DISPLAY 'Expression 2 is true.'
WHEN OTHER
DISPLAY 'Neither is true.'
END-EVALUATE

View file

@ -1,8 +1,16 @@
if2( some expression that results in a boolean value, some other expression that results in a boolean value.)
if2( some-expression-that-results-in-a-boolean-value, some-other-expression-that-results-in-a-boolean-value)
/*this part is a REXX comment*/ /*could be a DO structure.*/
select /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
when if.11 /*{condition 1 & 2 are true}*/ then perform-a-REXX-statement
when if.10 /*{condition 1 is true}*/ then " " " "
when if.01 /*{condition 2 is true}*/ then " " " "
when if.00 /*{no condition is true}*/ then " " " "
select
when if.11 {condition 1 & 2 are true} then perform-a-REXX-statement.
when if.10 {condition 1 is true} " " " " "
when if.01 {condition 2 is true} " " " " "
when if.00 {no condition is true} " " " " "
end
/*an example of a DO structure for the first clause: */
when if.11 /*{condition 1 & 2 are true}*/ then do; x=12; y=length(y); end

View file

@ -1,20 +1,23 @@
/*REXX program introduces IF2, a type of four-way compound IF: */
/*REXX program introduces IF2, a type of a four-way compound IF: */
parse arg bot top . /*obtain optional arguments from the CL*/
if bot=='' | bot==',' then bot=10 /*Not specified? Then use the default.*/
if top=='' | top==',' then top=25 /* " " " " " " */
w=max(length(bot), length(top)) + 10 /*W: max width, used for displaying #. */
do n=10 to 20 /*put DO loop through it's paces.*/
/* [↓] divisible by 2 and/or 3? */
if2( n//2==0, n//3==0) /*use the four-way IF statement.*/
select /*now, test the 4 possible cases.*/
when if.11 then say n "is divisible by both two and three."
when if.10 then say n "is divisible by two, but not by three."
when if.01 then say n "is divisible by three, but not by two."
when if.00 then say n "is neither divisible by two, nor by three."
otherwise nop /* ◄─┬─this statement is optional*/
end /*select*/ /* ├─ and only exists in case */
end /*n*/ /* ├─ one or more WHENs (above)*/
/* └─ are omitted. */
exit /*stick a fork in it, we're done.*/
/*──────────────────────────────────IF2 routine─────────────────────────*/
if2: parse arg if.10, if.01 /*assign the cases 10 and 01 */
if.11= if.10 & if.01 /* " " case 11 */
if.00= \(if.10 | if.01) /* " " " 00 */
return '' /*return to the invoker of IF2. */
do #=bot to top /*put a DO loop through its paces. */
/* [↓] divisible by two and/or three? */
if2( #//2==0, #//3==0) /*use a new four-way IF statement. */
select /*now, test the four possible cases. */
when if.11 then say right(#,w) " is divisible by both two and three."
when if.10 then say right(#,w) " is divisible by two, but not by three."
when if.01 then say right(#,w) " is divisible by three, but not by two."
when if.00 then say right(#,w) " isn't divisible by two, nor by three."
otherwise nop /*◄──┬◄ this statement is optional and */
end /*select*/ /* ├◄ only exists in case one or more*/
end /*#*/ /* └◄ WHENs (above) are omitted. */
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────IF2 routine───────────────────────────────*/
if2: parse arg if.10, if.01 /*assign the cases 10 and 01 */
if.11= if.10 & if.01 /* " " case 11 */
if.00= \(if.10 | if.01) /* " " " 00 */
return ''

View file

@ -0,0 +1,9 @@
(defmacro if2 (cond1 cond2 both first second . neither)
(let ((res1 (gensym))
(res2 (gensym)))
^(let ((,res1 ,cond1)
(,res2 ,cond2))
(cond ((and ,res1 ,res2) ,both)
(,res1 ,first)
(,res2 ,second)
(t ,*neither)))))