2021: Examples of CAS-type programs
|
05-07-2021, 02:26 AM
(This post was last modified: 05-08-2021 03:26 PM by compsystems.)
Post: #13
|
|||
|
|||
RE: 2021 Examples of CAS-type programs
"WHEN" "IFTE"and "()?" CMDS
WHEN CMD 4 arguments 1: test to solve 2: action for true 3: action for false 4: optional if you cannot solve the test with 4 args PHP Code: #cas test_whencmd_cas_0(eeee) > "other" with 3 args PHP Code: #cas as function PHP Code: #cas test_whencmd_cas(true); [enter] returns true test_whencmd_cas(false); [enter] returns false purge(x); test_whencmd_cas(x); [enter] returns ((x)? true : false) test_whencmd_cas(1); test_whencmd_cas(0); test_whencmd_cas(-1); [enter] returns true, false, true with (?) infix operator PHP Code: #cas as function PHP Code: #cas test_questionmarkcmd_cas(1); test_questionmarkcmd_cas(0); test_questionmarkcmd_cas(-1); [enter] returns true, false, true test_questionmarcmd_cas(x); [enter] returns ((x)? true : false) with IFTE cmd, the test must always return a numerical value PHP Code: #cas as function PHP Code: #cas test_iftecmd_cas(1); test_iftecmd_cas(0); test_iftecmd_cas(-1);test_iftecmd_cas(true); test_iftecmd_cas(false); [enter] 1, 0, 1, 1, 0 test_iftecmd_cas(x); [enter] IFTE(x,1,0) ifte + := operator ifte(true,(testvar1:=123),(testvar2:=456)); [enter] returns 123 ok [up] [up] [copy] [enter] ok ifte(false,(testvar1:=123),(testvar2:=456)); [enter] returns 456 ok purge(testvar1, testvar2); ifte(true,(123=>testvar1),(456=>testvar2)); ? + => operator (true)? (123=>testvar1): (456=>testvar2); [enter] returns 123 ok, (false)? (123=>testvar1): (456=>testvar2); [enter] returns 456 ok, but [up] [up][copy] [enter] "sto 123:testvar4 not allowed! Error: Bad Argument Type" Cause of the problem: the parentheses are suppressed in the arguments (123=>testvar3) to 123=>testvar3, this means that it cannot be interpreted |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)