[Push] Push2 Fibonacci Code
Lee Spector
lspector at hampshire.edu
Sat Nov 1 13:15:09 EST 2003
Rud,
Float.% in my Lisp version (and I believe in the C++ version that will soon
be released) is doing the generic MOD built in to Common Lisp, which works
for any real numbers and is defined in the Common Lisp hyperspec
(http://www.lispworks.com/reference/HyperSpec/Body/f_mod_r.htm) as:
mod performs the operation floor on number and divisor and returns the
remainder of the floor operation
furthermore:
floor ... produces a quotient that has been truncated toward negative infinity
and:
The remainder is ... a float if either x or y is a float .
I've extracted this from more complicated text that describes how it works
on various kinds of numbers... more details and examples are available from
the above URL.
So it's meaningful in the sense of being well defined. Whether it's
meaningful in the sense of being useful is up for grabs.
On your fibonacci (factorial) question: When I've run this before I always
provided the data input separately, either as a separate argument to
RUNPUSH or, when using PUSH-TEST, in a file called push.input. But I just
tried providing it in the code itself, exactly as you specified, and this
also works for me in both cases as well. (That is, data input of 5 leaves
120 on the integer stack.) I'm using the complete configuration, generated
from the GENERATE-FULL-CONFIG-FILE function in my Lisp implementation.
It's not clear to me whether you're working with my code or your own... If
the former then let me know and I'll send you the most current version of
push2.lisp -- I'm waiting to post it until it is polished, but I'm happy to
provide it to individuals.
-Lee
At 5:16 PM -0500 10/31/03, Rud Merriam wrote:
>Lee,
>
>My Push2 interpreter is running with the operations necessary to execute
>the Fibonacci example. The file input I used is
>
>( 5
> CODE.QUOTE
>( CODE.QUOTE ( INTEGER.POP 1 )
> CODE.QUOTE
> ( CODE.DUP INTEGER.DUP 1 INTEGER.- CODE.DO INTEGER.* )
> INTEGER.DUP
> 2
> INTEGER.<
> CODE.IF )
>CODE.DO)
>
>In your interpreter are you reading in two separate files, one for the
>program and the other for the data?
>
>In your configuration file you are loading FLOAT.%. Does a floating
>modulus operator have meaning?
>
>Rud
>K5RUD
>
>
>
>
>_______________________________________________
>Push mailing list
>Push at lists.hampshire.edu
>http://lists.hampshire.edu/mailman/listinfo/push
--
Lee Spector
Dean, School of Cognitive Science
Associate Professor of Computer Science lspector at hampshire.edu
Cognitive Science, Hampshire College http://hampshire.edu/lspector/
Amherst, MA 01002 413-559-5352, Fax: 413-559-5438
More information about the Push
mailing list