2021-07-07 11:20:14 <eli_oat > within a word, I'm hoping to do something like this -- #1 #10 n:between? [ normal ] case where, if a number is within a certain range a quote will be executed. I don't think case can handle this, though

2021-07-07 11:26:45 <rick_carlino1> eli_oat: I think you just want a nested IF statement for that don't you?

2021-07-07 11:27:04 <eli_oat > 🤔

2021-07-07 11:28:34 <eli_oat > nesting an if in a quote?

2021-07-07 11:29:10 <rick_carlino1> Are you trying to do something different than #1 #10 n:between? [ normal ] if ?

2021-07-07 11:30:23 <eli_oat > I wanna execute 1 branch if between 1 - 10, another if between 11 - 20, another between 21 - 30, etc.

2021-07-07 11:30:33 <rick_carlino1> ahhh

2021-07-07 13:09:19 eli_oat: try this: http://forth.works/share/8d899d501cac472a5eece8ac479a8f7e

2021-07-07 13:10:00 (sorry for not getting to reply sooner; it's been a busy day)

2021-07-07 13:10:43 <eli_oat > no worries!

2021-07-07 13:10:50 <eli_oat > I should have been working when I was nerd sniped

2021-07-07 13:38:09 <eli_oat > thanks so much for this crc!

2021-07-07 13:38:19 <eli_oat > I'm gonna need some time to grok this, but I think it'll do the trick!

2021-07-07 14:14:02 <eli_oat > crc, in the example you just provided what do 'abc and 'aabc do?

2021-07-07 14:14:05 <eli_oat > Are they templates?

2021-07-07 14:16:57 <rick_carlino1> eli_oat: Those are used to reorder the stack. RetroForth's reorder word accepts two strings. One represents the pre condition, the other represents the way you want the stack to be.

2021-07-07 14:17:31 <eli_oat > ah, and so this dups the first item on the stack?

2021-07-07 14:17:31 <rick_carlino1> It does some magic under the hood to re-arrange the stack implicitly to whatever the author chooses.

2021-07-07 14:18:20 <rick_carlino1> Yeah

2021-07-07 14:18:33 so it's like dup?

2021-07-07 14:18:41 but with more flexibility

2021-07-07 14:19:02 <rick_carlino1> In this case yes. I saw it referred to as "the ultimate stack juggler" in the docs heh

2021-07-07 14:19:28 <rick_carlino1> You can do any type of stack juggle with it though. Eg 'abc 'aaa reorder would work too

2021-07-07 14:20:00 <rick_carlino1> so in my example above, it would be like doing drop drop dup, but easier to comprehend (and probably slower, from what I've read in the docs)

2021-07-07 14:20:40 <rick_carlino1> My understanding of my encounters with it in example code, docs, etc.. is that it makes the code easier to read but also suffers some perf. penalties as a tradeoff.

2021-07-07 14:21:41 <eli_oat > gnarly -- that is wild. I'm totally smitten. Thanks for the explainer!

2021-07-07 14:22:28 <rick_carlino1> Also interesting if you find yourself unable to come up with clever stack juggles: http://sovietov.com/app/forthwiz.html

2021-07-07 14:24:27 <eli_oat > WAAAHT IZ DIS MAJIK!?

2021-07-07 14:25:47 <rick_carlino1> Pretty neat, eh? Sometimes I will write stuff with reorder and then go back later and refactor it to use whatever that thing suggests^

2021-07-07 14:30:00 rick_carlino1: thanks for answering

2021-07-07 14:30:19 eli_oat: in this case, it's duping the third item on the stack

2021-07-07 14:30:23 <rick_carlino1> np crc!

2021-07-07 14:31:35 reorder is a useful tool. It's really handy, but not at all efficient if performance matters.

2021-07-07 14:33:18 [ over swap ] dip should do the same as the 'abc 'aabc reorder

2021-07-07 14:34:35 <eli_oat > intriguing

2021-07-07 14:34:40 <eli_oat > I'm excited to play with this!

Proxy Information
Original URL
gemini://retroforth.org/irclogs/2021-07-07
Status Code
Success (20)
Meta
application/octet-stream
Capsule Response Time
511.619647 milliseconds
Gemini-to-HTML Time
1.174816 milliseconds

This content has been proxied by September (ba2dc).