I'm trying to write native pop11 implementations of the shootout
tests (http://alioth.debian.org). Unfortunately, I'm completely
flummoxed
by the simple effort of converting input parameters into numbers.
For example, here's an attempt at writing a simple Ackermann's
function:
==================================================
;;; $Id: ackermann.poplisp,v 1.1 2003/06/25 09:57:13 dada Exp $
define fast_ack (m, n) -> result;
if m == 0 then
n + 1 -> result
elseif n == 0 then
fast_ack(m - 1, 1) -> result
else
fast_ack(m - 1, fast_ack(m, n - 1)) -> result
endif
enddefine;
define get_args() -> result;
if null(pop11::poparglist) then
1 -> result
else
strnumber( hd(pop11::poparglist) ) -> result
endif
enddefine;
vars n;
get_args() -> n;
format_print('Ack(3,~D): ~D\n', [^n ^(fast_ack(3, n))]);
===============================================
Now, the thing that's causing me so much trouble is the use of the
"strnumber" procedure, which is apparently defined in a "string"
library
according to the HELP system.
But if I try to compile the procedures, I get errors:
brent@hopper:/opt/shootout/shootout/bench/ackermann$ poplog pop11
ackermann.poplog 2
Sussex Poplog Version 15.53
;;; DECLARING VARIABLE pop11
;;; IN FILE /opt/shootout/shootout/bench/ackermann/ackermann.poplog
;;; LINE 18
;;; MISHAP - STRING NEEDED
;;; INVOLVING: <undef pop11>
;;; FILE : /opt/shootout/shootout/bench/ackermann/ackermann.poplog
;;; LINE NUMBER: 27
;;; DOING : strnumber get_args trycompile
brent@hopper:/opt/shootout/shootout/bench/ackermann$
Apparently I need to tell Poplog to include the "string" library. So,
if I use
the "uses string;" declaration at the top of the file, I get this:
brent@hopper:/opt/shootout/shootout/bench/ackermann$ poplog pop11
ackermann.poplog 2
Sussex Poplog Version 15.53
;;; MISHAP - LIBRARY FILE NOT FOUND
;;; INVOLVING: strings
;;; FILE : /opt/shootout/shootout/bench/ackermann/ackermann.poplog
;;; LINE NUMBER: 4
;;; DOING : loadlib do_load uses_lib_idents trycompile
brent@hopper:/opt/shootout/shootout/bench/ackermann$
I've grepped through the Poplog sources to see if anything else in the
system uses the
"string" library, but find nothing. If I search for a library called
"string.p" or "string.ph" I
find nothing.
I also tried searching for "strings.p" and "strings.ph" to no avail.
I am really new with Poplog, so I'm surely missing some trivial aspect
of this, but I'm
a bit lost. Can anyone provide some clues?
Thanks,
-Brent
|