User talk:Chunes: Difference between revisions

reply
(reply)
 
(18 intermediate revisions by 4 users not shown)
Line 52:
 
:The idea is putting the loop entirely inside the <code>To demonstrate input:</code> routine so that you don't need any global flags. This can be done concisely with <code>Repeat.</code> by itself at the end of the routine. The loop will begin again from the top of the routine. I also used <code>repeat</code> when a negative number is encountered to act like a <code>continue</code> does in most other languages. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 17:03, 25 September 2020 (UTC)
 
:: Thanks for your suggestions; they all seem much more natural than my original implementation. I decided to go with the first approach and updated the factorial entry accordingly. --[[User:Dick de Bill|Dick de Bill]] ([[User talk:Dick de Bill|talk]]) 22:02, 25 September 2020 (UTC)
 
== "Runtime Evaluation" Quackery ==
 
I just noticed your addition to Runtime Evaluation. Thank you. I totally missed the task description. Mea culpa. --[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 21:53, 23 February 2021 (UTC)
 
== Loop Downward - off by one start value? ==
 
Hi, first of all: I love Plain English, great stuff. Thanks!
 
When reading Loops/Downward, [https://rosettacode.org/wiki/Loops/Downward_for#Plain_English Loops Downward], I stumbled over the initial value being 11. Should be 10, I guess. Or do I miss something? Best regards. [[User:Cg|Cg]] ([[User talk:Cg|talk]]) 13:39, 10 Dec 2020 (CET)
 
:<code>If a counter is below a number</code> is a decider (boolean function) that looks like this:
 
:<lang plainenglish>To decide if a counter is below a number:
Subtract 1 from the counter.
If the counter is less than the number, say yes.
Say no.</lang>
 
:So it subtracts 1 from the counter before performing the comparison. This often works out nicely but it can make some things awkward. One could just as easily make a version that performs the comparison first and then adds one to the counter on the way out, or avoid using a routine like this altogether.
 
:When reading a routine like this, it's important to keep in mind that all values are passed by reference (by default) in Plain English. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 13:57, 10 December 2020 (UTC)
 
== Quackery Bug Report ==
 
FYI, rational numbers are off the menu until I fix "round" in bigrat.qky. Guess my testing wasn't as thorough as I thought. It may be a while, mediant rounding is complicated. I'll let you know.--[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 23:02, 26 January 2021 (UTC)
 
::Well, I have a fix that looks like it might work. But I have no idea why the **** <code>round</code> only works all the time with negative numbers. If you want to play with bigrat before I've convinced myself it's right now, here's what I ''think'' it should be.
::<lang> [ temp put
2dup v0< not iff
[ -v ' -v ]
else []
unrot
v.initcf
[ v.nextcf
dup 0 = dip
[ dup v.nextdenom
swap v.nextnumer
max temp share > ]
or until ]
v.getnumer v.getdenom
rot do
temp release ] is round ( n/d n --> n/d )</lang>--[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 23:51, 26 January 2021 (UTC)
 
::: Thanks for the heads up. I'll hold off on tasks that prefer/require rational numbers for now. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 02:56, 27 January 2021 (UTC)
 
::::I figured it out to my satisfaction. Looks like the problem was with /mod, which rounds towards negative infinity. I'm pretty sure that what is required for mediant rounding is "round away from zero", and forcing positive numbers to temporarily be negative achieves that. Please don't ask me why - I'm not that much of a mathematician.<br><br>With that disclaimer, I'm going to mention the Factor results for [http://www.rosettacode.org/wiki/Convert_decimal_number_to_rational#Factor Convert decimal number to rational] - those unnecessarily big numbers are not dissimilar to some of the weird output I was getting. It's suggestive that a similar problem may be at play there. IF (and it's a big IF) it's doing mediant rounding, it really should be able to hit the answers on the nose...<lang>O> [ dup echo$
... say " is "
... $->v drop
... dup 100 > if
... [ say "approximately "
... proper 100 round
... improper ]
... vulgar$ echo$
... say "." cr ] is task ( $ --> )
...
 
Stack empty.
 
/O> $ "0.9054054 0.518518 0.75" nest$ witheach task
...
0.9054054 is approximately 67/74.
0.518518 is approximately 14/27.
0.75 is 3/4.
</lang>I know Factor is processing floating point and I'm processing strings, so it may just be that. Anyway up, it's back to more checking, double checking, triple checking ... for me.<br>--[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 20:11, 28 January 2021 (UTC)
 
::::: Glad you figured it out! Btw, I like your translation of Oforth in the Pi task. I can't get over the elegance of the meta control flow words. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 21:12, 30 January 2021 (UTC)
 
::::::Yeah, the meta words were something that gave me a real "Holy Crap!!!" moment during development. I knew from Lisp that there was goodness in metadata, and from Phil Koopman's book [https://users.ece.cmu.edu/~koopman/stack_computers/ Stack Computers] that there was goodness to be found in making Every. Single. Op-code. The. Same. Size. so those were guiding principle. The first Holy Crap around control flow was "nests always start at 0 and end at -1, and everything is the same size, so I can do control flow without needing to make it something special for the compiler to deal with - there's no "where do I need to jump to?" the answer is "the start", "the end" or "over 1 or 2 from here". The meta- aspect came about because I was getting all knotted up trying to get <code>traverse()</code> to work whilst the control flow words screwed about with the program counter. (My mam used to work at a massive petroleum cracking plant. (ICI Billingham) The engineers there regularly worked on thousands of volts DC live whilst standing on layers of rubber mats. Once in a while one would hand a spanner to his mate, ''not on a mat'', and get flung across the room. Working live on stuff can suck.) My coding woes all disappeared as soon as I decided to modify the PC at arm's length by working on the return stack instead. And so the meta-words were born. THEN I got the second "Holy Crap when it dawned on me what potential they had.<br><br>(Incidentally, there are more meta- operators than are strictly necessary - <code>]else[</code> can be replaced by <code>]'[ drop</code>, and <code>]iff[</code> with <code>]if[ ]'[ drop</code> (probably ... it dawned on me a couple of weeks ago and I haven't actually tested it to be 100% sure.)<br><br>The only thing I haven't explored the potential of is <code>]do[</code> and … thinking about it while I type … that means I haven't stress tested it and … OMG! I'll be back in a few minutes. … … … Yup, I thought so. There was a bug-in-waiting there. Fortunately it was a quick fix and the code is shorter and marginally faster as a result. :-) That'll be included when I release the fix to bigrat.qky.<br><br>Pi … the final phase of testing bigrat is coding some stuff that I didn't think of in case my internal biases are guiding me around writing code that will uncover bugs. So I've found a few suitable tasks in RC and coded those, and they work. :-) And while I was looking for stuff I chanced on Pi and thought, well that'll be quick and easy and I've been wanting to do a Pi spigot since I heard of them. I do enjoy watching endless digits scroll up the screen.<br><br>Now all I need to do is update TBoQ and bounce it all up to GitHub. I'll leave it a day or two though in case anything else dawns on me.<br>--[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 01:06, 31 January 2021 (UTC)
 
:: Updated version uploaded to GitHub. [https://github.com/GordonCharlton/Quackery Here.]<br><br>--[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 13:33, 2 February 2021 (UTC)
 
::: Thanks. --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 13:59, 2 February 2021 (UTC)
 
== You got credited on British TV show QI's Facebook page. ==
 
Hi,
 
Spotted your moniker on my Facebook newsfeed. Looks like they found your Cistercian Numerals task and borrowed the graphic.
 
(This link should work without needing to sign up for/log into FB.)
 
https://www.facebook.com/OfficialQI/posts/pfbid02UWvqebk57mU1ziAbVSZgqSEjN4TYiqwY1bSyWXcxMJDq7Wzk9MnHPip9NrqvaYJnl
 
--[[User:GordonCharlton|GordonCharlton]] ([[User talk:GordonCharlton|talk]]) 06:40, 3 November 2022 (UTC)
 
: Thanks for the heads up. It's always nice to see people using my stuff. :) --[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 22:28, 3 November 2022 (UTC)
1,808

edits