Post Reply 
New to programming
06-10-2015, 01:24 AM (This post was last modified: 06-10-2015 01:24 AM by Clod.)
Post: #1
New to programming
Hi everyone! I've recently purchased the HP-Prime and I'm struggling to get a program of my own to work. First I did the following one:

Code:

#cas
tvf(H,Xi):=
BEGIN
  LOCAL ans;
  ans:=limit(H*Xi,x,0);
  return ans;
END;
#end

Which works just fine... Howeeeeeeeeeeeeeeeeeeever, it seems I'm not able to use the "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass). So, I t[/code][/php]ried to do this next:

Code:

EXPORT PROGRAMS(H,Xi)
BEGIN
  LOCAL ans;
  ans:=CAS.limit(H*Xi,X,0);
  return ans;
END;

This one has two problems. The first one, it won't allow you to use the "x" in lowercase (so I have to use the uppercase one, which is bothersome) aaaaaaand whenever the answer is infite or zero it just return an "undefine"... Could someone help me out please? Big Grin
Find all posts by this user
Quote this message in a reply
06-10-2015, 04:56 AM (This post was last modified: 06-10-2015 04:56 AM by Clod.)
Post: #2
RE: New to programming
Got the answer by myself. Just read some of the old posts, sorry for not doing it sooner :C

Hope this helps other lazy people like me Tongue

Code:

EXPORT tvf(H,Xi)
BEGIN
  LOCAL ans:= CAS.limit(H*Xi,"x",0);
  return ans;
END;
Find all posts by this user
Quote this message in a reply
06-10-2015, 06:32 AM
Post: #3
RE: New to programming
(06-10-2015 01:24 AM)Clod Wrote:  Howeeeeeeeeeeeeeeeeeeever, it seems I'm not able to use the "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).

The CAS programs are not visible as other programs in the Toolbox > User menu but they are listed in the Vars > CAS menu, so you can access them without having to spell them on the keyboard.

On this topic, there is a great article from Han in the Article Forum section: HP Prime CAS Programming.
Find all posts by this user
Quote this message in a reply
06-10-2015, 06:33 AM
Post: #4
RE: New to programming
Did you know that if you write a cas program it is listed under Vars/CAS/Program not in the Toolbox/User section? I think that is not too clearly arranged, but in an other post Tim pointed out that they chose that until they find a perfect solution for the filesystem.

I am not sure if you knew because of
Quote: "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).
Find all posts by this user
Quote this message in a reply
06-11-2015, 02:19 AM (This post was last modified: 06-11-2015 02:41 AM by Clod.)
Post: #5
RE: New to programming
(06-10-2015 06:32 AM)Didier Lachieze Wrote:  
(06-10-2015 01:24 AM)Clod Wrote:  Howeeeeeeeeeeeeeeeeeeever, it seems I'm not able to use the "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).

The CAS programs are not visible as other programs in the Toolbox > User menu but they are listed in the Vars > CAS menu, so you can access them without having to spell them on the keyboard.

On this topic, there is a great article from Han in the Article Forum section: HP Prime CAS Programming.

(06-10-2015 06:33 AM)Angus Wrote:  Did you know that if you write a cas program it is listed under Vars/CAS/Program not in the Toolbox/User section? I think that is not too clearly arranged, but in an other post Tim pointed out that they chose that until they find a perfect solution for the filesystem.

I am not sure if you knew because of
Quote: "EXPORT XXX()" command which would allow me not to write "tvf()" manually (which is a pain in the ass).

Thanks for your responses. By the way, I'm having trouble trying to add this:

LOCAL ans:= CAS.limit(H*Xi*x,"x",0);

I dunno why it doesn't work the way I want to... :C
It won't compile... and changing it to "x" will return a "Bad Argument Value"

From the link you people provided, I could make this one work just fine:

Code:
EXPORT TVF(H,Xi)
BEGIN
  LOCAL cmd:= "limit(" +H*Xi+ "*x,x,0)";
  CAS(cmd)
END;

But I find that kind of coding messy and ugly :/
Find all posts by this user
Quote this message in a reply
06-11-2015, 03:07 AM
Post: #6
RE: New to programming
(06-11-2015 02:19 AM)Clod Wrote:  
(06-10-2015 06:32 AM)Didier Lachieze Wrote:  The CAS programs are not visible as other programs in the Toolbox > User menu but they are listed in the Vars > CAS menu, so you can access them without having to spell them on the keyboard.

On this topic, there is a great article from Han in the Article Forum section: HP Prime CAS Programming.

(06-10-2015 06:33 AM)Angus Wrote:  Did you know that if you write a cas program it is listed under Vars/CAS/Program not in the Toolbox/User section? I think that is not too clearly arranged, but in an other post Tim pointed out that they chose that until they find a perfect solution for the filesystem.

I am not sure if you knew because of

Thanks for your responses. By the way, I'm having trouble trying to add this:

LOCAL ans:= CAS.limit(H*Xi*x,"x",0);

I dunno why it doesn't work the way I want to... :C
It won't compile... and changing it to "x" will return a "Bad Argument Value"

From the link you people provided, I could make this one work just fine:

Code:
EXPORT TVF(H,Xi)
BEGIN
  LOCAL cmd:= "limit(" +H*Xi+ "*x,x,0)";
  CAS(cmd)
END;

But I find that kind of coding messy and ugly :/

I don't have my Prime in front of me and I don't have the emulator on this machine, either. That said, does:

CAS.limit("H*Xi*x","x",0);

work?

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
06-11-2015, 04:20 AM
Post: #7
RE: New to programming
(06-11-2015 03:07 AM)Han Wrote:  
(06-11-2015 02:19 AM)Clod Wrote:  Thanks for your responses. By the way, I'm having trouble trying to add this:

LOCAL ans:= CAS.limit(H*Xi*x,"x",0);

I dunno why it doesn't work the way I want to... :C
It won't compile... and changing it to "x" will return a "Bad Argument Value"

From the link you people provided, I could make this one work just fine:

Code:
EXPORT TVF(H,Xi)
BEGIN
  LOCAL cmd:= "limit(" +H*Xi+ "*x,x,0)";
  CAS(cmd)
END;

But I find that kind of coding messy and ugly :/

I don't have my Prime in front of me and I don't have the emulator on this machine, either. That said, does:

CAS.limit("H*Xi*x","x",0);

work?

Nope, it returns 0, no matter what the inputs are :C
Find all posts by this user
Quote this message in a reply
Post Reply 




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