The following warnings occurred:
Warning [2] Undefined array key 255914 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 256203 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 256300 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 256300 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





[Prime]Passing lists as arguments



#4

I'm trying to create some functions to manipulate Quaternions which are complex numbers with 4 dimensions. I chose a list as my base implementation type. I'm encountering a behaviour I don't understand--passing one list works okay, but passing two lists does not.

This function works:

EXPORT Q_CAST(a)
BEGIN
CASE
IF type(a)=6 THEN RETURN a; END;
IF type(a)=0 THEN RETURN {a,0,0,0}; END;
IF type(a)=3 THEN RETURN {RE(a),IM(a),0,0}; END;
IF TYPE(a)=4 THEN RETURN {a[0],a[1],a[2],a[3]}; END;
DEFAULT
RETURN EXPR(a);
END;
END;

If I call Q_CAST(4), I get {4,0,0,0}; Q_CAST(1+2*i) = {1,2,0,0}; and QCAST({1,2,3,4}) = {1,2,3,4}. All as I would expect.

However, this function does not work.

EXPORT Q_Add(a,b)
BEGIN
LOCAL m,n;
m:=Q_CAST(a);
n:=Q_CAST(b);
RETURN {m[0]+n[0],m[1]+n[1],m[2]+n[2],m[3]+n[3]};
END;

Any time I try to pass a list to Q_Add, it fails like so:

Q_Add({1,2,3,4},{2,3,5,9})
Error:Invalid Input

Starting it in the debugger, I get two fields, a and b, but I am unable to start debugging if I attempt to pass a list as an argument to either. Debugging Q_CAST does not let me pass a list either, but it seems to work just fine from the command-line. (Which does seem like a separate type of bug--shouldn't you be able to debug programs that don't take numerical arguments?)

Both of these are subroutines with a program I've called Quaternion, so I would expect that they have the exact same environment. I have also tried using different parameter and variable names, including uppercased names--to no avail. I've also tried assigning an empty list to m or n first, but that didn't work. I don't know if I'm even getting that far.

It would seem logical that a program argument would override the scope of any global variables, so I'm not surprised that changing the names didn't solve the problem. However, the Prime seems to be full of non-orthogonal behaviour or otherwise hidden quirks that trip up programmer types like myself. For example Home vs CAS, Textbook vs RPN, Global vars with specific types, etc, etc. (For the record, I'm trying to use using Home mode with textbook entry. As non-RPN doesn't allow operator overloading, RPN would be definitely better for operating on constructing data types because you can naturally use arithmetic-type operators. I'm avoiding it for now because I don't want to introduce any more issues and RPN mode seems to have its own share of pitfalls.)

Is passing lists as arguments known to have issues, or is there some "magic" that is needed to make this work?


#5

hello

1 indexed lists got you! the following program works fine...

EXPORT Q_Add(a,b)
BEGIN
LOCAL m,n;
m:=Q_CAST(a);
n:=Q_CAST(b);
RETURN {m[1]+n[1],m[2]+n[2],m[3]+n[3],m[4]+n[4]};
END;

have fun,

Cyrille


#6

That's the problem!

If I might, here are a couple suggestions for the next Prime update that would tremendously help diagnosing situations like this:

1) Return "Array index error" instead of "invalid input" as an error in this situation
2) If a function fails, report the line number that it fails on
3) Allow the debugger to pass non-numeric arguments to a function.

Any one (but all three especially) would have helped me figure this out on my own.

Thank you Cyrille.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: Lists in programs Alberto Candel 7 3,404 12-04-2013, 02:16 AM
Last Post: Alberto Candel
  hp prime - programming with lists giancarlo 3 1,819 11-10-2013, 02:13 AM
Last Post: Giancarlo
  HP Prime SIZE and OBJ-> with matrices/vectors/lists Helge Gabert 8 2,695 09-27-2013, 05:44 PM
Last Post: Helge Gabert
  Nothing like passing the time away... Eddie W. Shore 2 1,339 03-21-2013, 08:23 AM
Last Post: Eddie W. Shore
  HP28C/S ROM entry point lists update Christoph Giesselink 0 927 01-31-2013, 02:21 PM
Last Post: Christoph Giesselink
  Invisible message passing Jim Yohe 4 1,604 04-04-2011, 02:15 PM
Last Post: Ken Shaw
  HP41 Mcode: SELPF arguments Meindert Kuipers 3 1,292 01-28-2010, 03:14 PM
Last Post: PeterP
  50g vector or complex arguments in exact form? Hal Bitton in Boise 2 1,016 01-30-2008, 03:25 AM
Last Post: George Bailey (Bedford Falls)
  Testing UserRPL arguments for numerosity? Sleazey 2 1,027 05-18-2007, 02:20 PM
Last Post: Sleazey
  Another example of passing off of MoHPC pictures on ebay Noname 1 852 02-22-2005, 05:59 PM
Last Post: hugh steers

Forum Jump: