Re: balanced REDUCE: a challenge for the brave



Gerry <gerry@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
Coos Haak <chfo...@xxxxxxxxx> wrote:
schreef Gerry:

If there was something below the 0 at the bottom of the list on the
stack, (reduce) can be simplified to:

: (reduce)
   2dup * if

\ Strange, what if x is 256 on a 16 bit or 65536 on a 32 bit CPU?

Dammit, Google Groups just misfired on me. I meant to continue that
2dup m* or
should work.

\ Why not simply
     dup 0= if

because it's tring to filter out ( 0 ) and ( 0 x )

OK, I didn't think of that and I had the complication of not knowing how deep the stack was, and I couldn't test the second item until the first had succeeded because there might not be a second item.

But if we just put two zeros down instead of one then it's easy.

( 0 0 x? x? x? ) OVER 0= IF

When we're down to two or three items the second item has to be a zero.
.



Relevant Pages

  • Re: calling a RM function which is placed below 1 MB
    ... Zeros it all so this should not matter isn't it? ... Ciao Ephraim ... that I need to call a 16Bit real Mode function placed ... stack, or ss:sp must point to a valid real mode stack. ...
    (comp.os.msdos.djgpp)
  • Re: DRAM data persistence
    ... If you extend the stack ... int main ... Yes, it seems you are right, I get all zeros too with it. ... FILE *fptr; ...
    (sci.electronics.design)
  • Re: 2.6.17-rc5-mm2
    ... That's contrary to common use. ... detects the return address column in the unwind info being set to ... undefined and treats that as an end of stack. ... other zeros you encounter as problems. ...
    (Linux-Kernel)
  • Re: Why does the stack have a fixed size?
    ... upper bound on stack size is known. ... >> These are just ordinary COW stacks, ... fully allocated on startup and filled with zeros. ... Sure, but I would be at least somewhat surprised (well, it's Windows, ...
    (comp.lang.functional)