50g group photo

Yahoo Groups archive

50g

Archive for 50g.

Index last updated: 2026-03-30 00:59 UTC

Thread

IFTE in RPN

IFTE in RPN

2009-05-16 by Michael

I was trying to use IFTE in RPN rather than algebraic, and can't figure it out

On the stack, I assume I want -

* Test value
* Value to put on stack if test value is true
* Value to put on stack if test value is false

Say I want something like -

<< -> n 1 n <= 1 'f(n-1)' IFTE >>

Where I am defining a recursive function f(), and I want to execute f(n-1) if n < 1. This is not working.

I am not sure why.

Re: IFTE in RPN

2009-05-16 by Michael

--- In 50g@yahoogroups.com, "Michael" <me@...> wrote:
>
>
> I was trying to use IFTE in RPN rather than algebraic, and can't figure it out
>
> On the stack, I assume I want -
>
> * Test value
> * Value to put on stack if test value is true
> * Value to put on stack if test value is false
>
> Say I want something like -
>
> << -> n 1 n <= 1 'f(n-1)' IFTE >>
>
> Where I am defining a recursive function f(), and I want to execute f(n-1) if n < 1. This is not working.
>
> I am not sure why.
>

I think I figured out my own error. I was running the program off the stack, but calling an incorrectly saved version in f(). In other words the program on the stack was not matching the stored prog, and it's recursive, so that was a problem.

Referencing program from within itself (WAS: IFTE in RPN)

2009-05-17 by matthiasrampke

I have a followup question. Is there (in UserRPL) a way for a program to reference (run or RCL) itself if it is not stored in a variable? That would make such recursive programs more self-contained.

thanks, m.

--- In 50g@yahoogroups.com, "Michael" <me@...> wrote:
>
>
>
> I think I figured out my own error. I was running the program off the stack, but calling an incorrectly saved version in f(). In other words the program on the stack was not matching the stored prog, and it's recursive, so that was a problem.
>