when cmd

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

when cmd

Message par compsystems » jeu. mai 06, 2021 4:07 pm

Hello I have problems defining a function in xcas

Code : Tout sélectionner

function f(testvar):={
   return when( testvar, true, false );
}:;
Syntax compatibility mode: xcas
Parse error line 1 column 20 at :=

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: when cmd

Message par compsystems » ven. mai 07, 2021 2:31 am

this way it works fine.

Code : Tout sélectionner

function f(testvar)
  return when( testvar, true, false );
end;
purge(x); f(x); [Enter] returns ((x)? true : false)

and why doesn't it return an error message ""Unable to check test Error: Bad Argument Value"

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: when cmd

Message par parisse » ven. mai 07, 2021 6:23 am

Your first attempt should be without the keyword function.
when does not error if the test value is unknown, it returns the argument un-evaluated.

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: when cmd

Message par compsystems » ven. mai 07, 2021 4:24 pm

Hello, in the case of the first post, this is the template that Xcas puts in the installation version for PC
Prg Menu New prg

about When cmd, I think it is very important to define a fourth parameter, that is, if it cannot evaluate to a logical value (firts arg), execute the fourth argument, this is important to define custom output messages or execute a third option T/F another, I think this is how the When command Works in the Texas instrument calculators.

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: when cmd

Message par parisse » sam. mai 08, 2021 10:26 am

compsystems a écrit :
ven. mai 07, 2021 4:24 pm
Hello, in the case of the first post, this is the template that Xcas puts in the installation version for PC
Prg Menu New prg
Indeed, will be fixed.
about When cmd, I think it is very important to define a fourth parameter, that is, if it cannot evaluate to a logical value (firts arg), execute the fourth argument, this is important to define custom output messages or execute a third option T/F another, I think this is how the When command Works in the Texas instrument calculators.
when already accepts a 4th argument.

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: when cmd

Message par compsystems » sam. mai 08, 2021 3:17 pm

when already accepts a 4th argument.
> but I think, it is not documented yet.

https://www-fourier.ujf-grenoble.fr/~pa ... _default52

parisse
Messages : 5731
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: when cmd

Message par parisse » sam. mai 08, 2021 6:55 pm

Unfortunately that's the case of many compatibility commands, it would require much work to provide complete documentation...

compsystems
Messages : 554
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: when cmd

Message par compsystems » lun. mai 10, 2021 3:25 am

Updating documentation takes time, but if these little ones get lost, it will be more difficult

It seems to me that it is important to update this command at least in the French document.

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(testvar):=
begin
return when( testvar, true, false, "other" );
end;
#end

Répondre