HP Forums

Full Version: [DOCUMENTATION] eval CMD
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello hp-prime developer group

I can not find information about the eval command in lower case, please attach it in the user guide or HELP menu

Examples that can help document it.

on HOME MODE the key [eval] put EVAL
'4/2' [ENTER] ->'4/2'
EVAL(Ans) ->2

on CAS MODE the key [eval] put eval
type(set[1,2,3]) ->DOM_LIST
eval(Ans) -> DOM_LIST //OK
Eval does not evaluate constant identifiers, this is correct because it is within the symbolic environment

with EVAL
type(set[1,2,3]) ->DOM_LIST
EVAL(Ans) -> 7 //OK

enum gen_unary_types {
    // immediate type (without mem allocation) should be < _ZINT
    _INT_= 0, // int val
    _DOUBLE_= 1, // double _DOUBLE_val
    // all type below or equal to _DOUBLE_ must be non pointers
    _ZINT= 2, // mpz_t * _ZINTptr
    _REAL= 3, // mpf_t * _REALptr
    // all type strictly below _CPLX must be real types
    _CPLX= 4, // gen * _CPLXptr
    _POLY= 5, // polynome * _POLYptr
    _IDNT= 6, // identificateur * _IDNTptr
    _VECT= 7, // vecteur * _VECTptr
    _SYMB= 8, // symbolic * _SYMBptr
    _SPOL1= 9, // sparse_poly1 * _SPOL1ptr
    _FRAC= 10, // fraction * _FRACptr
    _EXT= 11, // gen * _EXTptr
    _STRNG= 12, // string * _STRNGptr
    _FUNC= 13, // unary_fonction_ptr * _FUNCptr
    _ROOT= 14, // real_complex_rootof *_ROOTptr
    _MOD= 15, // gen * _MODptr
    _USER= 16, // gen_user * _USERptr
    _MAP=17, // map<gen.gen> * _MAPptr
    _EQW=18, // eqwdata * _EQWptr
    _GROB=19, // grob * _GROBptr
    _POINTER_=20, // void * _POINTER_val
    _FLOAT_=21 // immediate, _FLOAT_val
  } ;

You can take a look at the CAS source yourself and see exactly what is happening.

Home simply evaluates everything down as far as it can go. The CAS has special handling to keep those special values like DOM_LIST as strings.

Is there anything you are trying to say with this post?
Keep in mind that EVAL and eval are two separate commands. Most commands have only one form (uppercase). When a command exhibits different behavior when used as COMMAND vs. command, then this is often due to there being two different versions of the command (one for CAS and one for non-CAS).

Unfortunately, the CAS view (in Textbook mode) seems to always display a command in uppercase (even when not typed in uppercase) which suggests that the two forms are the same when in fact they are not.
Reference URL's