Post Reply 
HP Prime CAS programming
01-25-2020, 02:58 AM (This post was last modified: 05-06-2021 03:51 AM by compsystems.)
Post: #16
RE: HP Prime CAS programming
An alternative way to define functions is to use the following template

PHP Code:
#cas
function name(args)
   ...
   return ...
end;
#end 

and you can even delete the directive #end
PHP Code:
#cas
function name(args)
   ...
   return ...
end


standard notation for CAS programs

PHP Code:
#cas
name(args):=
begin
   
...
   return ...
end;
#end 

or without #end
PHP Code:
#cas
name(args):=
begin
   
...
   return ...
end

Example with standard CAS notation.
PHP Code:
// fract1( 320, 240, 10 )
#cas
fract1X_Y_Nmax ):=
BEGIN
    local x
yzcjwhres1res2;
    
//freeze;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1 := []; 
    
Y_ := Y_-1;
    for 
y from 0 to Y_ do
        
:= -2.1+i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixon_pxy126*j+2079 ));
            
:= c+w;
        
end;
    
end;
    
wait(0);
    return 
"Done"
end;
#end 


As function
PHP Code:
// fract2( 320, 240, 10 )
#cas
function fract2X_Y_Nmax )
    
local xyzcjwhres1res2;
    
//freeze;
    
:= 2.7/X_;
    
:= -1.87/Y_;
    
res1 := []; 
    
Y_ := Y_-1;
    for 
y from 0 to Y_ do
        
:= -2.1+i*(h*y+0.935);
        for 
x from 0 to X_-do
            
:= 0;
            for 
j from 0 to Nmax-do
                if 
abs:= z^2+)>2 then break; end;
            
end;
            
res1.appendpixon_pxy126*j+2079 ));
            
:= c+w;
        
end;
    
end;
    
wait(0);
    return 
"Done"
end;
#end 


With Python Syntax
// fract3( 320, 240, 10 )
PHP Code:
#cas
def fract3X_Y_Nmax ):
    
local xyzc
    
for x in rangeX_ ):
        for 
y in rangeY_ ):
            
0
            c 
2.7*X_-2.1 i*( -1.87*y/Y_ .935)
            for 
j in rangeNmax ):
                
z*c
                
if abs) > 2:  # abs(z = z*z+c)>2:
                    
break
            
pixon_pxy255*20*256 )
    
wait(0)
    return 
"Done"
#end 
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP Prime CAS programming - Han - 02-19-2015, 08:21 PM
RE: HP Prime CAS programming - salvomic - 02-19-2015, 08:41 PM
RE: HP Prime CAS programming - Han - 02-23-2015, 05:21 PM
RE: HP Prime CAS programming - dg1969 - 02-19-2015, 10:35 PM
RE: HP Prime CAS programming - rprosperi - 02-20-2015, 01:22 PM
RE: HP Prime CAS programming - Han - 02-21-2015, 03:21 AM
RE: HP Prime CAS programming - salvomic - 02-21-2015, 06:21 AM
RE: HP Prime CAS programming - rprosperi - 02-21-2015, 01:54 PM
RE: HP Prime CAS programming - pr0 - 03-30-2015, 04:29 PM
RE: HP Prime CAS programming - Han - 03-30-2015, 05:46 PM
RE: HP Prime CAS programming - Carlos295pz - 04-16-2017, 08:46 AM
RE: HP Prime CAS programming - leprechaun - 01-22-2020, 12:21 PM
RE: HP Prime CAS programming - Joe Horn - 01-22-2020, 01:02 PM
RE: HP Prime CAS programming - Tim Wessman - 01-22-2020, 01:15 PM
RE: HP Prime CAS programming - CyberAngel - 01-25-2020, 10:31 AM
RE: HP Prime CAS programming - compsystems - 01-25-2020, 02:40 PM
RE: HP Prime CAS programming - leprechaun - 01-22-2020, 03:09 PM
RE: HP Prime CAS programming - compsystems - 01-25-2020 02:58 AM
RE: HP Prime CAS programming - parisse - 01-26-2020, 07:42 AM
RE: HP Prime CAS programming - roadrunner - 08-29-2020, 11:25 AM



User(s) browsing this thread: 4 Guest(s)