The following warnings occurred:
Warning [2] Undefined array key 123453 - 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 123490 - 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 123495 - 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 123499 - 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 123570 - 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 123574 - 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 123575 - 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 123584 - 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 123610 - 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 123611 - 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 123584 - 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 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/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 array key 123611 - 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 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/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 array key 123610 - 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 332 ThreadedMode::buildtree
/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





Coin flip program



#7

Last night, I get funny idea to make program to simulate coin flip on 35s. This because wife and son say I not flipping coin right to see who win something.

Anyhow, I figure if I make program, it should be fair and not influence by human and odds should be 50/50. I also tell my son that on true false test, there is a 50/50 chance on getting answer correct, but there is a 90% chance you will pick the wrong answer (that was joke in Hungary).

F001 LBL F
F002 0.5
F003 RANDOM
F004 X>Y?
F005 GTO F008
F006 EQN HEADS
F007 GTO F001 // I DO THIS SO IT KEEP RECYCLING IF NEEDED
F008 EQN TAILS
F009 GTO F001
F010 RTN // NOT SURE IF THIS NEEDED, BUT IT HERE JUST IN CASE

I put RTN at F010, even though program should never get there. I just think it better programing practice to always end program formally.

I would be interested to hear what others say about that though.


#8

My friends, I thought I try this simple program and convert to RPL, but I have hard time with. Here is what I have.

<< IF RAND > .5 THEN
'HEADS'
ELSE 'TAILS'
END
>>

When I run it always head. Do I need store the randum number to a variable?

Also, it display this is stack

'HEADS'>.5624896409... 

That seem strange if you ask me.


#9

Hello,

please don't forget it's RPL;-)

The syntax of your IF clause should be as follows:

<<

IF RAND .5 >

THEN 'HEADS'

ELSE 'TAILS'

END

>>



HTH

Raymond


#10

Okay, so THEN and 'HEADS' must be on same line. I look at example I have in RPL guide and it have it differently. I will give this a try.

Thank you.

**EDIT** no, still always HEADS. I will look into assigning to variable first and see if that issue.

**Edit 2** I see what I do wrong. I not read your message properly and see that .5 come before greater than sign. Yes, Víncze, Reverse Polish Lisp. Think reverse.

Okay, now it work nicely. Thank you my friend.

Edited: 28 Aug 2007, 3:37 p.m.


#11

It would be better to return character strings than global names, so I'd use "HEADS" and "TAILS" instead of 'HEADS' and 'TAILS'.

Assuming that the AUR manual is correct, RAND returns a value in the range 0<=x<1, so for true 50/50 probabilities, use something like:

%%HP: T(3)A(R)F(.);
\<< IF RAND .5 \>= THEN "HEADS" ELSE "TAILS" END \>>
or:
%%HP: T(3)A(R)F(.);
\<< IF RAND .5 < THEN "TAILS" ELSE "HEADS" END \>>
In the above, "%%HP: T(3)A(R)F(.);" is an "ASCII transfer header" that would allow you to copy and paste the source code to a file for transferring to a calculator. It tells the calculator, first off, that it is an ASCII transfer, then which translation mode (0 through 3) to use, then which angular mode (DEG, RAD, or GRAD) to use, and which of period or comma is the "fraction mark". For small programs such as these, one would likely just key in the program, but the transfer header tells just how to key it in, although the angular mode doesn't matter for these particular cases.

"\<<" and "\>>" represent the UserRPL program delimiters, and "\>=" represents the "greater than or equal to" symbol.

In RPL source code, a "line" is pretty much meaningless, except that a LineFeed code always end any comment. You could put everything on a single line, use one line for each "word", indent some lines, or whatever you choose. If a source code delimiter doesn't already do so, then "separators", such as spaces, ASCII control codes, semicolon, or whichever of period or comma isn't the fraction mark, tell the compiler where one "word" ends and the next begins. Such source code "formatting" is up to the programmer, and each tends to use his own particular formatting "style"; for example, with a longer program, I'd use something like:

%%HP: T(3)A(R)F(.);
\<<
IF
RAND
.5 \>=
THEN
"HEADS"
ELSE
"TAILS"
END
\>>

Getting back to RAND, it would be possible to cheat with your program by setting the seed with the RDZ command. With any given seed, the numbers returned by a series of RAND commands is repeatable, although rather difficult to "predict" without actually trying it, thus you could "preview" the sequence of "HEADS" and "TAILS" returned after "initializing" the seed with the RDZ command.

Regards,
James


#12

If we're going to dig in and alter the code, I'd do it this way:

    << "HEADS" "TAILS" RAND .5 < IFTE >>

Smaller, faster and less easy to understand :-)

- Pauli


#13

Quote:
If we're going to dig in and alter the code, I'd do it this way:

    << "HEADS" "TAILS" RAND .5 < IFTE >>

Smaller, faster and less easy to understand :-)


But to make it actually work:
%%HP: F(.);
\<< RAND .5 < "HEADS" "TAILS" IFTE \>>

Regards,
James


#14

oops :-)

Teach me to not try out the code before posting.


- Pauli

#15

Quote:
If we're going to dig in and alter the code, I'd do it this way:

    << "HEADS" "TAILS" RAND .5 < IFTE >>

Smaller, faster and less easy to understand :-)

- Pauli


IFTE?? IF Than Else?

Yes, much smaller and very not easy to understand, but yes efficient (I think).

#16

Quote:
It would be better to return character strings than global names, so I'd use "HEADS" and "TAILS" instead of 'HEADS' and 'TAILS'.

Yes, I actually did that, but did not update my code online
Quote:
Assuming that the AUR manual is correct, RAND returns a value in the range 0<=x<1, so for true 50/50 probabilities, use something like:
%%HP: T(3)A(R)F(.);
\<< IF RAND .5 \>= THEN "HEADS" ELSE "TAILS" END \>>
or:
%%HP: T(3)A(R)F(.);
\<< IF RAND .5 < THEN "TAILS" ELSE "HEADS" END \>>

Yes, I realize this after I post. I make same change.
Quote:
In the above, "%%HP: T(3)A(R)F(.);" is an "ASCII transfer header" that would allow you to copy and paste the source code to a file for transferring to a calculator. It tells the calculator, first off, that it is an ASCII transfer, then which translation mode (0 through 3) to use, then which angular mode (DEG, RAD, or GRAD) to use, and which of period or comma is the "fraction mark". For small programs such as these, one would likely just key in the program, but the transfer header tells just how to key it in, although the angular mode doesn't matter for these particular cases.

"\<<" and "\>>" represent the UserRPL program delimiters, and "\>=" represents the "greater than or equal to" symbol.

In RPL source code, a "line" is pretty much meaningless, except that a LineFeed code always end any comment. You could put everything on a single line, use one line for each "word", indent some lines, or whatever you choose. If a source code delimiter doesn't already do so, then "separators", such as spaces, ASCII control codes, semicolon, or whichever of period or comma isn't the fraction mark, tell the compiler where one "word" ends and the next begins. Such source code "formatting" is up to the programmer, and each tends to use his own particular formatting "style"; for example, with a longer program, I'd use something like:

%%HP: T(3)A(R)F(.);
\<<
IF
RAND
.5 \>=
THEN
"HEADS"
ELSE
"TAILS"
END
\>>

Getting back to RAND, it would be possible to cheat with your program by setting the seed with the RDZ command. With any given seed, the numbers returned by a series of RAND commands is repeatable, although rather difficult to "predict" without actually trying it, thus you could "preview" the sequence of "HEADS" and "TAILS" returned after "initializing" the seed with the RDZ command.

Regards,
James


This all good information, and thank you my friend for sharing with me. It always goo to learn from someone who know more and I appreciate your help.


Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 2,616 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  Flip Flap--15C battery bay flaps Matt Agajanian 3 1,343 03-04-2012, 07:17 PM
Last Post: Raymond Del Tondo
  current draw from CR2032 coin cells Eric Smith 5 1,836 11-04-2010, 12:32 AM
Last Post: hpnut
  CR2032 coin cells 20 for $5 designnut 2 1,096 04-15-2009, 09:33 PM
Last Post: Paul Dale
  Mini challenge - coin toss MikeO 33 6,381 03-23-2009, 03:54 PM
Last Post: htom trites jr
  HP-41 MCODE: Making an MCODE program call another MCODE program Geir Isene 10 2,772 01-13-2008, 05:58 AM
Last Post: Raymond Del Tondo
  42s hardcover flip-case ECL 2 1,008 11-09-2005, 11:51 AM
Last Post: Richard Garner

Forum Jump: