axiom-developer
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Axiom-developer] [#90 coredump with infinite stream]


From: anonymous
Subject: [Axiom-developer] [#90 coredump with infinite stream]
Date: Wed, 09 Feb 2005 06:55:05 -0600

++added:

\begin{verbatim}

++added:


??changed:
-
-This is likely due to stack overflow (previously reported). The construct for 
smallerThan require Axiom to test EVERY element in the stream to see if s < n. 
There is no reason why Axiom should complain. Axiom is not designed to be able 
to figure out a general formula for the nth entry of the output stream for 
smallerThan whose signature is:
-smallerThan: (Stream Integer, PositiveInteger)->Stream Integer
-
-To do what you are trying to do, try this:
\end{verbatim}

This is likely due to stack overflow (previously reported). The construct for 
smallerThan requires Axiom to test EVERY element in the stream to see if s < n. 
There is no reason why Axiom should complain. Axiom is not designed to be able 
to figure out a general formula for the nth entry of the output stream for 
smallerThan whose signature is:

\begin{verbatim}
smallerThan: (Stream Integer, PositiveInteger) -> Stream Integer
\end{verbatim}

To do what you are trying to do, do this:

??changed:
-primes:Stream Integer := generate(nextPrime, 2)
-lessThan(stream, n) == filterWhile(s+->s<n, stream)
-lessThan(primes, 5)
)clear all
p:Stream Integer := generate(nextPrime, 2)
filterWhile(s+->s<5, p)

??changed:
-entries primes
entries p

??changed:
-The expected result would be the first 11 (default stream length) entries.
The expected result would be the first 11 (default stream length) entries. And 
here is another problem:

\begin{axiom}
lessThan(n)==
  g(s)== (s < n)
  print(g(3))
  filterWhile(g, p)
lessThan(5)
\end{axiom}

The local function g is not compiled correctly because n is not passed to it. 
So it compiles as false for all input.  The same error occurs in the NAG 
version.
One  would then expect Axiom to go into an infinite loop if we use not(s$<$n). 
But Axiom is "smart enough" to know and creates the stream even though the 
answer is still wrong.

\begin{axiom}
lessTest(n)==
  g(s) == not(s < n)
  print(g 3)
  filterWhile(g, p)
lessTest(5)
\end{axiom}

\begin{axiom}
largerThan(st,n)==[s for s in st | not(s < n)]
largerThan(p,5)
\end{axiom}

This one below crashes, but not for the NAG version, which gives the correct 
answer.

\begin{axiom}
before(st, n)==filterWhile(s+-> s < n, st)
before(p,5)
\end{axiom}

And this also crashes (whereas it does NOT crash for NAG version, giving the 
correct answer).
\begin{axiom}
lessThan(n)==filterWhile(s+-> (s < n), p)
lessThan(5)
\end{axiom}

William

--
forwarded from http://page.axiom-developer.org/zope/mathaction/address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]