Little explorations with HP calculators (no Prime)
|
06-01-2017, 07:44 PM
(This post was last modified: 06-01-2017 07:54 PM by Vtile.)
Post: #221
|
|||
|
|||
RE: Little explorations with the HP calculators
(06-01-2017 07:00 PM)pier4r Wrote: I was able only to find this reference:I think you are now falling to two similar, but not identical language trap! That thread is pure newRPL discussion. NewRPL allows persistent comments with that format, while userRPL do not. UserRPL is memory optimised in that regard, it cuts the comments out to preserve precious |
|||
06-01-2017, 10:19 PM
(This post was last modified: 06-05-2017 01:54 PM by pier4r.)
Post: #222
|
|||
|
|||
RE: Little explorations with the HP calculators
but there are programs shared in the past with "@@" comments before newRPL was a thing.
And I learned the hard way that if I write: @ this is a comment containing an @ in the middle I get 'in' 'the' 'middle' on the stack. So either a string of consecutive "@" is stripped, or "@@" for me would mean "start a comment and stop it immediately". --- --- Aside from that, I am stuck in a relatively simple, although non standard, probabilistic problem because, well, I am still not good enough. Maybe someone here has an idea. So I know (or I think I know) the formula to compute the expected value given a probability density (discrete or not). I wanted to extend it to a new "dice". The new dice is given by the following procedure: I roll a dice 5 times in a row and I count the number of double ones that appears. That is , if I get the series 51161 I count 1, because there are only two ones appearing one after another. If I get 51116 , I count 2 double ones. 5[11]16 and 51[11]6. Of course something like 41356 has 0 double ones. So given a dice that returns those "results", I started to make a list of useful combinations: - 1 is were I expect a one - x is where I expect 2 to 6 - y is where I expect 1 to 6 , it is an isolated one. - only one double: 11xxy, 11xyx, x11xy, yx11x, yxx11, xyx11 probability for each series is 5*5*6/6^5 = 5^2/6^4 - two doubles: 111xy x111x yx111 probability 5*6/6^5 for the ones with y and 5^2/6^5 for the one with only x - two doubles: 11x11 prob 5/6^5 - three doubles: 1111x x1111 prob 5/6^5 - four doubles: 11111 prob: 1/6^5 expected amount of double ones: 6 * 1 * 5^2/6^4 + 2 * 2 * 5/6^4 + 2 * 5^2 / 6^5 + 2 * 5/6^5 + 2 * 3 * 5 / 6^5 + 4 * 1 / 6^5 = 0.14326 All the rest has 0 double ones, so it does not matter in the computation. Now, since I'm not sure, I also did a program to count for me (see below) but I got: 10 "rolls of this dice" produce an average of 0.1 100 produces 0.11 1000 produces 0.108 10000 produces 0.1092 So it does seem that either my code or my formula above is wrong and I would say my formula is wrong. Any ideas? edit: I ended up counting overlapping solutions. This guy helped, so my formula above is wrong when I count 11xxy and 11xyx (I count in one place 2-6 and then 1-6, therefore counting overlapping sequences) My code is right though. Power of computer science for the ones that performs poorly with math. Code:
---- update 2017 06 05 how to execute programs in other directories: http://www.hpmuseum.org/forum/thread-228...l#pid20222 Wikis are great, Contribute :) |
|||
06-13-2017, 09:49 AM
(This post was last modified: 06-13-2017 10:00 AM by pier4r.)
Post: #223
|
|||
|
|||
RE: Little explorations with the HP calculators
So since some weeks I have two hp 50g. The second is assigned to newRPL (as soon as I get grip with it through the desktop version). I decided today to make use of the second (I see possible double usage with standard rom, so I may get a third 50g just to be sure) so I have two 50g connected via usb to a win XP system.
The conn4x anyway, fails to detect the one that has the Xserver running. Is that normal? I mean one 50g is visualizing the stack, the other the Xmodem Server , but conn4x just goes in loop (not always). With one 50g connected I have no problems. Is that normal? Wikis are great, Contribute :) |
|||
06-15-2017, 01:09 PM
(This post was last modified: 06-15-2017 01:30 PM by pier4r.)
Post: #224
|
|||
|
|||
RE: Little explorations with the HP calculators
I would like to share a simple program for backup up a directory from home to the SD card.
The examples that I found on this site (search string site:hpmuseum.org sd backup) use heavily the stack - while I like named variables, especially for things that do not have to be fast - and do not use the sdlib included with the sdfiler. Since I would have liked to see an example with a different layout and I did not find it, I share mine to raise the chances that a reader, for example me in the future, can have another idea. The program is far from being general, it is just an example how a backup program can be done. Code:
Other useful topics that I found (but based heavily on stack operations): - http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=126574 - http://www.hpmuseum.org/cgi-sys/cgiwrap/...ead=112771 (maybe the comp.sys.hp48 is a better archive for RPL questions , especially reading messages from 2010 or before, sometimes people address that newsgroup . Searching for sd backup) - ok maybe this program http://page.mi.fu-berlin.de/raut/WR49/Filer6.htm from this page http://page.mi.fu-berlin.de/raut/WR49/index.htm#General may help - https://groups.google.com/forum/#!search...7AI-5vHWQJ this is the discussion about the sdfiler from TW and Claudio L. themselves. Wikis are great, Contribute :) |
|||
09-09-2017, 09:21 PM
Post: #225
|
|||
|
|||
RE: Little explorations with the HP calculators
New little problem. I could not translate it in a list problem or a string processing problem therefore I post it in this thread that is more of a "catch all!" of my posts.
So there is a park with paths that can be seen as two squares, one in another. The internal square is constructed linking the middle points of the sides of the bigger square. Alan and Bob start running in the same point (one middle point of the bigger square), only Alan keeps running on the bigger square and Bob on the internal one. Both have the same pace. Question: (a) assuming that they have unlimited capacity and they keep running forever, would they meet again in a place while running? (b) (the question that I wanted to convert in list/string processing . Inspired by the recent posts of Gerald H about sequences) . Assuming that the bigger square has vertex A, B, C, D and middle points E, F, G, H. IAlan and Bob start Both in the point E. Alan goes through E, A, B, C, D, A, B, C, D, A, ... Bob goes through E, F, G, H, E, F, G, H Every time that Bob reaches a vertex of the square EFGH, is Alan ahead, considering only the current lap of Alan having checkpoints E,F,G or H? For example, from the start: entry, Alan, Bob : 0, E, E - same 1, behind, F 2, behind , G 3, behind, H 4, behind, E 5, ahead, F (Alan is near to reach E, while Bob is only at F) 6, behind, G 7, behind, H 8, behind, E 9, ahead, F (Alan is past G) 10, ahead, G (alan is past H) etc... Therefore what we want is: given the value N (N > 0), determine if for the entry "N" Alan is ahead of Bob according to the description given above. Wikis are great, Contribute :) |
|||
09-09-2017, 10:03 PM
(This post was last modified: 09-09-2017 10:14 PM by Joe Horn.)
Post: #226
|
|||
|
|||
RE: Little explorations with the HP calculators
(09-09-2017 09:21 PM)pier4r Wrote: (a) assuming that they have unlimited capacity and they keep running forever, would they meet again in a place while running? If Alan and Bob are mathematical points with no extension, then NO. Let's assume that the outer perimeter is 4. At all 4 midpoints, the distance covered by the outer runner will always be a rational number, and the distance covered by the inner runner will always be an irrational number, and hence never equal. The same logic applies regardless of the actual measurements. If Alan and Bob are actual physical beings, then YES. If they never speed up, slow down, or veer off course, then bumping into each other is inevitable. EDIT: The first paragraph is only true in an abstract, non-physical reality. In THIS universe, where everything seems to be made up of discrete quanta, I suppose even infinitely small points would eventually meet as they hop-scotch in contiguous, minuscule jumps (quantum leaps?), rather than moving smoothly and continuously, along their respective paths. <0|ɸ|0> -Joe- |
|||
09-10-2017, 09:55 AM
Post: #227
|
|||
|
|||
RE: Little explorations with the HP calculators
Ok while the other problem is still open (1), a new one.
given 4 different positive integers: a, b, c, d . Find all the quadruplets where all the terms are smaller than 1000, that satisfy the following identify (a+b) / (c+d) = (a-b) / (c-d) (I did not attack it yet). Bonus: do the same for positive integers: a, b, c, d where there are at least 3 different integers. Once again, I do not see how those can be list/string challenges, if someone has an idea, he is welcomed! (note1) or better, I think that getting the information whether Alan is ahead of Bob for the entry N should be not that complicated unless I am mistaken. Wikis are great, Contribute :) |
|||
09-10-2017, 10:46 AM
Post: #228
|
|||
|
|||
RE: Little explorations with the HP calculators | |||
09-11-2017, 09:21 PM
(This post was last modified: 09-11-2017 10:25 PM by Gilles59.)
Post: #229
|
|||
|
|||
RE: Little explorations with the HP calculators
(09-10-2017 10:46 AM)AlexFekken Wrote: Don't want to spoil too much of the fun but this is equivalent to a / b = c / d <> 1. That's a lot ! HP50G '(a+b) / (c+d) = (a-b) / (c-d)' 'a' ISOL -> a=(c.b)/d That means (if we dont care about 2 same values of a b c d), that the number of quadruplets is the sum of the divisors of c*b for c:1->999, b:1->999 Quick and dirty HP50G + GoferList: Code: « Get ready for ~ 1000000 Shift CONT ex : { { 'a=2' 'd=7' 'b=14' 'c=1' } { 'a=7' 'd=2' 'b=14' 'c=1' } } |
|||
09-24-2017, 08:17 PM
(This post was last modified: 09-24-2017 08:47 PM by pier4r.)
Post: #230
|
|||
|
|||
RE: Little explorations with HP calculators (pre Prime)
Sometimes this problems happens to me but finally I decode it. (I asked this already but I was not sure)
in userRPL if I write a comment like this: @@test in the program on the calculator 'test' is left . Does that mean that @this is a comment until the end of the line while @this is a comment until the next at@ while this are program statements is until the second '@' ? Does anyone know the proper behavior of how '@' is interpreted in all cases? edit: I wonder when I will learn all the useful things on the 50g. If you have the clock on the screen on the 50g, and the 50g is buy in a long computation, the clock won't be updated, giving you an idea for how long the system has been under load. Wikis are great, Contribute :) |
|||
09-25-2017, 12:12 AM
Post: #231
|
|||
|
|||
RE: Little explorations with HP calculators (pre Prime)
(09-24-2017 08:17 PM)pier4r Wrote: in userRPL if I write a comment like this: I only know that it starts ignoring at the first @, and stops ignoring after the next @, hence one reason why it's difficult to embed email addresses in a comment. This doesn't hold true for @ inside " or ' though, otherwise we'd be in all sorts of bother. Others will be able to perhaps quote chapter/verse of applicable manuals. (Post 94) Regards, BrickViking HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a) |
|||
09-25-2017, 12:23 AM
Post: #232
|
|||
|
|||
RE: Little explorations with HP calculators (pre Prime)
(09-24-2017 08:17 PM)pier4r Wrote: Sometimes this problems happens to me but finally I decode it. (I asked this already but I was not sure) From the AUR, p. 1-7: Creating Programs on a Computer It is convenient to create programs and other objects on a computer and then load them into the calculator. If you are creating programs on a computer, you can include “comments” in the computer version of the program. To include a comment in a program: Enclose the comment text between two @ characters. or Enclose the comment text between one @ character and the end of the line. Whenever the calculator processes text entered in the command line — either from keyboard entry or transferred from a computer — it strips away the @ characters and the text they surround. However, @ characters are not affected if they’re inside a string. I agree, there is always something new to learn about the 50g. --Bob Prosperi |
|||
10-17-2017, 08:18 AM
(This post was last modified: 10-17-2017 01:19 PM by pier4r.)
Post: #233
|
|||
|
|||
RE: Little explorations with HP calculators (pre Prime)
Interesting bit (maybe only interesting for me).
As I (maybe) wrote I am using one of my 50g for a long term project named "life gamification". It is nothing else that collecting data from my point of view to evaluate how I perceived my days. I hope to write a little summary about it but the idea is more or less similar to the one mentioned in the following article: https://hackernoon.com/how-data-forced-m...df76064903 So far I collected 132 days of data, mostly in a directory made out of lists of reals (the total size of the directory is 11 KB on the calculator). What I do after every collected day is a backup, with a rough script that sometimes requires two executions (see below) and is likely not safe after hundreds of executions due to name conflicts. After several backups done with the method mentioned above, I browse the SD with the SD filer and I rename the backups done, plus I move them in a precise subfolder on the SD card. Well today, after having some 30+ objects in the root folder of the SD card, the SD filer stopped working. (sd filer: http://www.hpcalc.org/details/6524 + ) I tried a soft reset (on + F3) but nothing. I may have to reinstall the library, I am not sure, but I was not expecting it. Another bit: already some weeks ago, browsing with the SDfiler the content of the SD, I noticed that sometimes the SD filer was unable to report all the files in a folder 50+ of them (in particular the 'final' folder where I save the backups). Of , say 60 files, only 40 or 50 were listed. Code:
edit: after some hours, SDfiler works again (I recalled the sdlib first to see if it had the same problem). Dunno why. Wikis are great, Contribute :) |
|||
10-17-2017, 01:34 PM
(This post was last modified: 10-17-2017 01:46 PM by pier4r.)
Post: #234
|
|||
|
|||
RE: Little explorations with HP calculators (pre Prime)
Another topic.
I realized (maybe a little too late) that syntax highlighting helps even with concise languages, especially if I am used to use notepad++ . Has anyone done a user defined language for userRPL for notepad++? I tried to search it via google but with no useful results. Of course I decided to do my version since it is not difficult to do (I will include it in the next hp calc torrent ) but if someone has already an advanced work, it would be worth it, I think. Otherwise I will include keywords as soon as I encounter them, so not very quickly. Wikis are great, Contribute :) |
|||
10-17-2017, 04:46 PM
Post: #235
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Some news about the userRPL user defined language for notepad++ (once again, if someone has a more complete version, please let me know).
It helps quite a bit note the variables, have to be called lvname to be highlighted. I hope to adjust it later for newRPL as well, since the newRPL desktop version can import text files. (I will include it also in the next torrent release, then you can give me feedback if you want) I used it to test a solution to a micro problem that was since long time in my todo list. One has processes that print on the console and locks. One should define the different processes in a way that they coordinate to print the wanted pattern even if the execution is randomly picking between the two processes. So the basic is to have the process A and the process B (or 1 and 2) and to print 1,2,1,2,1,2 etc.. This gets more complicated if the pattern to produce is more complicated and there are more processes involved. For the moment, though, I am happy that I was able to find a way to test it on the hp 50g. Below the first working solution. Of course, from real problem solving - especially if one is not that good like me - new questions arise so I am going to ask the following: To "pack" a command to be executed I discovered the following method: "statements" OBJ\-> instead of the more verbose \<< statements \>> (note that with a text expander like fastKeys on windows - aText on mac - one could produce \<< \>> quite quickly with shortcuts) Do you know any other way? In particular could be possible to pack and entire program in a string or block of some type and then execute it in "pieces" in a proper way? Code:
Wikis are great, Contribute :) |
|||
10-22-2017, 08:50 AM
Post: #236
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Little discovery about SREPL (likely documented somewhere but not in the 50g AUR).
SREPL returns L2: string with replacements done L1: number of substitutions L1 in output is not mentioned by the AUR. Practical example. From list in RPL to array for javascript (using highcharts.js for plotting, recommended!): Code:
Wikis are great, Contribute :) |
|||
10-22-2017, 01:52 PM
Post: #237
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(10-22-2017 08:50 AM)pier4r Wrote: Little discovery about SREPL (likely documented somewhere but not in the 50g AUR). This is an error in the AUR. I don't know of anywhere it is correctly documented. |
|||
10-22-2017, 03:51 PM
(This post was last modified: 10-22-2017 08:42 PM by pier4r.)
Post: #238
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
Thanks John!
Another tip. While playing around with large lists (1000 elements) I noticed that ADD was not that fast. So quick test ADD vs DOLIST: 1000 elements (repeated only once) ADD ~ 5 seconds DOLIST ~ 5.6 seconds Code:
edit: Another info generating 1000 values in a list with the SIN function takes time. if, after every value, one stores it in a list with STO+ it takes around 600 seconds. Wikis are great, Contribute :) |
|||
10-22-2017, 08:30 PM
Post: #239
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(10-22-2017 01:52 PM)John Keith Wrote:(10-22-2017 08:50 AM)pier4r Wrote: Little discovery about SREPL (likely documented somewhere but not in the 50g AUR). Speaking of the AUR for the 50g/49g+/48gII, is there a list of errata/omissions since the document was last published? If so, is this omission mentioned on that errata? (Post 120) Regards, BrickViking HP-50g |Casio fx-9750G+ |Casio fx-9750GII (SH4a) |
|||
10-22-2017, 11:05 PM
Post: #240
|
|||
|
|||
RE: Little explorations with HP calculators (no Prime)
(10-22-2017 03:51 PM)pier4r Wrote: generating 1000 values in a list with the SIN function takes time. Adding elements to a list one by one is very inefficient and causes a lot of garbage collection. It is much faster to accumulate the elements on the stack, then combine them into a list like so: Code: \<< 1. 1000. FOR j j SIN which takes about 12.2 seconds on my 50g. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)