Post Reply 
[HELP] Understanding the operation of CAS object types
12-04-2016, 08:09 PM (This post was last modified: 12-07-2016 03:31 PM by compsystems.)
Post: #1
[HELP] Understanding the operation of CAS object types
HELLO

"type" HELP SAYS
Quote:Syntax: type(Expr)
Returns n in [1..12] that defines the type of the argument
Example: type("abc") returns DOM_STRING
EVAL(DOM_STRING) returns 12

"TYPE" HELP SAYS
Quote:Syntax:
TYPE(object)
Returns the type # of the object:
0: Real TYPE(π)
1: Integer TYPE(#6h)
2: String TYPE("A+B")
3: Complex TYPE(3+4*i)
4: Matrix TYPE([1,2,3])
5: Error TYPE(EXAMPLE?)
6: List TYPE({1,2,3})
8: Function TYPE(x+3)
9: Unit TYPE(5_m)
14.? : CAS object. the fractional part is the CAS type

I do not understand 14. # someone knows an example?


A program that shows the output of (TYPE versus type) commands, if you know the example for types (3,5,9,...) please inform me
type cmd
PHP Code:
#cas
    
types():= 
    
begin
        
// Nov 5 2016 
        
print;
        print( 
"type cmd" );        
        print( 
"❑ Float:    type( 3.14 ) → "    type3.14 ) + " # " + EVAL( type(3.14)) ); // DOM_FLOAT // 1
        
print( "❑ Integer:    type( #6h )  → "    type#6h ) + " # " + EVAL( type(#6h)) ); // DOM_INT // 2
        
print( "❑ Integer:    type( true ) → "    typetrue ) + " # " + EVAL( type(true)) ); // DOM_INT // 2
        
print( "❑ 3 " ); // example ?
        
print( "❑ Complex:type( 3+4*i ) → "  type3+4*) + " # " + EVAL( type(3+4*i)) ); // DOM_COMPLEX // 4     
        
print( "❑ 5 " ); // example ?
        
print( "❑ Identifier: type( x )    → "     type) + " # " + EVAL( type(x)) ); // DOM_IDENT // 6
        
print( "❑ Identifier: type( π )    → "     typeπ ) + " # " + EVAL( type(π)) ); // DOM_IDENT // 6
        
print( "❑ Array:    type( [[1,2],[y,4]] ) → "     type( [[1,2],[y,4]] ) + " # " + EVAL( type([[1,2],[3,4]] )) ); // DOM_LIST // 7
        
print( "❑ List:        type( {1,{2,3},[x]} ) → "     type( {1,{2,3},[x]} ) + " # " + EVAL( type({1,{2,3},[4]} )) ); // DOM_LIST // 7 
        
print( "❑ List:        type( list[1,{2,3},[x]] ) → "     type( list[1,{2,3},[x]] ) + " # " + EVAL( type( list[1,{2,3},[x]] )) ); // DOM_LIST // 7 
        
print( "❑ Poly:type( poly1[1,-6,11,6] ) → "     typepoly1[1,-6,11,6] ) + " # " + EVAL( typepoly1[1,-6,11,6])) ); // DOM_LIST // 7 
        
print( "❑ Set:        type( set{1,2,3} ) → "     type(set[1,2,3]) + " # " + EVAL(type(set[1,2,3])) ); // DOM_LIST // 7 
        
print( "❑ Symbolic:type( 'A+B' ) → "     type'A+B' ) + " # " + EVAL(type('A+B')) ); // DOM_SYMBOLIC // 8
        
print( "❑ Symbolic: type( 5_m ) → "  type5_m ) + " # " + EVAL(type(5_m)) ); // DOM_SYMBOLIC // 8
        
print( "❑ 9-11 " ); // examples ?
        
print( "❑ String:  type( \"A+B\" ) → "  type"A+B" ) + " # " + EVAL(type"A+B" )) ); // DOM_STRING // 12
        
print( "❑ Function:type( f(x):=x+3) ) →"    typef(x):=x+) + " #" + EVAL( type(f(x):=x+)) ); // DOM_FUNC // 13
        
print( "❑ 14... ?" );
        print( 
"❑ SpecialFloat: type( 3°5′6″ ) → "  type3°5′6″ ) + " # " + EVAL(type3°5′6″ )) ); // DOM_SPECIALFLOAT // 21
        
return( "Done" );
    
end;
#end 

[Image: objectTypes_hp_prime_image01.png]

TYPE cmd
PHP Code:
EXPORT TYPES()
BEGIN
  
// Nov 5 2016 
  
print();
  print( 
"TYPE cmd" );
  print( 
"❑ Real:     TYPE( π )         → "  TYPEπ ) ); // 0
  
print( "❑ Real:     TYPE( 3°5′6″ )     → "  TYPE3°5′6″ ) ); // 0
  
print( "❑ Integer: TYPE( #6h )     → "  TYPE#6h ) ); // 1
  
print( "❑ String:     TYPE( \"A+B\" ) → "    TYPE"A+B" ) ); // 2
  
print( "❑ Complex: TYPE( 3+4*i )     → "  TYPE3+4*) ); // 3
  
print( "❑ Matrix:     TYPE( [[1,2],[3,4]] ) → "    TYPE( [[1,2],[3,4]] ) ); // 4
  //print( "❑ Error: "     + TYPE(?) );
  
print( "❑ List:      TYPE( {1,{2,3},[4]} ) → "     TYPE( {1,{2,3},[4]} ) ); // 6
  
  
print( "❑ Function: TYPE( 'A+B' )     → "  TYPE'A+B' ) ); // 8
  
print( "❑ Function: TYPE( CAS( \"f(x):=x+3\" ) )→ "    TYPEcas"f(x):=x+3" )) ); // 8  
  
print( "❑ Function: TYPE( CAS.( f(X):=X+3 ) )→ "    TYPECAS.( f(X):=X+)) ); // 8
  
print( "❑ Function: TYPE( f(X):=X+3 )→ "    TYPEf(X):=X+) );
  print( 
"❑ Unit:      TYPE( 5_m )     → "  TYPE(5_m) ); // 9

  
return( "Done" );
END

[Image: objectTypes_hp_prime_image00.png]
Find all posts by this user
Quote this message in a reply
12-04-2016, 09:50 PM (This post was last modified: 12-07-2016 03:24 PM by compsystems.)
Post: #2
RE: CAS object (Help with TYPE cmd)
The sentence inside "TYPES" prg does not work. Why?

PHP Code:
print("❑Function: TYPE(f(x):=x+3))-> "+TYPE(CAS::(f:=(x)->x+3))) 
Find all posts by this user
Quote this message in a reply
12-05-2016, 12:10 AM (This post was last modified: 12-05-2016 12:11 AM by Han.)
Post: #3
RE: CAS object (Help with TYPE cmd)
(12-04-2016 09:50 PM)compsystems Wrote:  The sentence inside "TYPES" prg does not work

PHP Code:
print("❑Function: TYPE(f(x):=x+3))-> "+TYPE(CAS::(f:=(x)->x+3))) 

What is CAS::(f:=(x)->x+3) ? There is no such construct in HPPL. The CAS command is invoked with CAS() or CAS.function() and not CAS::().

Use: TYPE(CAS("f:=(x)->x+3"))

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
12-05-2016, 02:29 PM (This post was last modified: 12-07-2016 03:25 PM by compsystems.)
Post: #4
RE:
HOME MODE X (defined variable to 0), x -> "Syntax Error" (best undefined variable)

case1: Why only capital X is valid as a symbolic variable? If the CAS command tells it to operate as symbolic arg.

TYPE CMD & CAS.() CMD

TYPE( CAS.( f(X):=X+3 )) [ENTER] returns 8 // X uppercase &
TYPE( CAS.( f(x):=x+3 )) -> "Syntax Error" Why? // x lowercase

type CMD & CAS.() CMD

type( CAS.( f(X):=X+3 )) -> 8
type( CAS.( f(x):=x+3 )) -> "Syntax Error" Why? /

----------------------------------

case2: Within a chain is indifferent X or x

TYPE CMD & CAS( "" ) CMD

TYPE( CAS( "f(X):=X+3" )) -> 8 // X uppercase
TYPE( CAS( "f(x):=x+3" )) -> 8 // x lowercase

type CMD & CAS( "" ) CMD

type( CAS( "f(X):=X+3" )) -> 8
type( CAS( "f(x):=x+3" )) -> 8

----------------------------------

case3:

TYPE CMD

TYPE( f(X):=X+3 ) -> 8 // // X uppercase
TYPE( f(x):=x+3 ) -> "Syntax Error" Why? / // x lowercase

type CMD

type( f(X):=X+3 ) -> 2 ??
type( f(x):=x+3 ) -> "Syntax Error" Why? /


CAS MODE

TYPE( CAS( "f(X):=X+3" )) -> "Error: Unmatch control word"
TYPE( CAS( "f(x):=x+3" )) -> "Error: Unmatch control word"


TYPE( CAS.( f(X):=X+3 )) -> 8
TYPE( CAS.( f(x):=x+3 )) -> 8

TYPE( f(X):=X+3 ) -> "Error: Unmatch control word"
TYPE( f(x):=x+3 ) -> "Error: Unmatch control word"

type( CAS( "f(X):=X+3" )) -> DOM_SYMBOLIC Why?
type( CAS( "f(x):=x+3" )) -> DOM_SYMBOLIC Why?

type( CAS.( f(X):=X+3 )) -> DOM_IDENT Why?
type( CAS.( f(x):=x+3 )) -> DOM_IDENT Why?

type( f(X):=X+3 ) -> DOM_FUNC
type( f(x):=x+3 ) -> DOM_FUNC

------
CAS:: () only CAS MODE

TYPE( CAS.( f(X):=X+3 )) [ENTER] returns 8 [UP] [UP] [COPY] TYPE(CAS::(f:=(X)->X+3))
TYPE(CAS:: (f:=(X)->X+3)) -> 8

type( CAS.( f(X):=X+3 )) [ENTER] returns DOM_IDENT [UP] [UP] [COPY] TYPE(CAS:: (f:=(X)->X+3))
type( CAS:: (f:=(X)->X+3)) -> DOM_IDENT
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: