|
|
last edited 7 years ago by oldk1331 |
1 2 3 4 | ||
Editor: oldk1331
Time: 2017/07/12 14:41:19 GMT+0 |
||
Note: |
added:
From oldk1331 Wed Jul 12 14:41:19 +0000 2017
From: oldk1331
Date: Wed, 12 Jul 2017 14:41:19 +0000
Subject:
Message-ID: <20170712144119+0000@axiom-wiki.newsynthesis.org>
Status: open => closed
I understand that the following is not a smart thing to do. Axiom should complain, but it just coredumps silently:
\begin{axiom} primes:Stream Integer := generate(nextPrime, 2) smallerThan(stream, n) == [ s for s in stream | s < n ] smallerThan(primes, 100) -- Axiom 3.0 Beta coredumps \end{axiom}
Matthias
The failure is unrelated to 100
. It fails with the value 5.
Tim
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:
(1) -> smallerThan: (Stream Integer,PositiveInteger) -> Stream Integer
To do what you are trying to do, do this:
)clear all
All user variables and function definitions have been cleared. p:Stream Integer := generate(nextPrime,2)
Line 2: p:Stream Integer := generate(nextPrime,2) ....................A Error A: syntax error at top level Error A: Improper syntax. 2 error(s) parsing
However, why should this give an error?
entries p
There are 1 exposed and 1 unexposed library operations named entries having 1 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op entries to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named entries with argument type(s) Variable(p)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need.
The expected result would be the first 11 (default stream length) entries. And here is another problem:
lessThan(n)== g(s)== (s < n) print(g(3)) filterWhile(g,p)
lessThan(5)
Compiling function g with type PositiveInteger -> Boolean There are 2 exposed and 0 unexposed library operations named filterWhile having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op filterWhile to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named filterWhile with argument type(s) FunctionCalled(g) Variable(p)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. Compiled code for g has been cleared. Compiled code for lessThan has been cleared. 1 old definition(s) deleted for function or rule g
Compiling function g with type PositiveInteger -> Boolean false There are 2 exposed and 0 unexposed library operations named filterWhile having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op filterWhile to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named filterWhile with argument type(s) FunctionCalled(g) Variable(p)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need.
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(sn). But Axiom is "smart enough" to know and creates the stream even though the answer is still wrong.
lessTest(n)== g(s) == not(s < n) print(g 3) filterWhile(g,p)
lessTest(5)
Compiled code for g has been cleared. 1 old definition(s) deleted for function or rule g
Compiling function g with type PositiveInteger -> Boolean There are 2 exposed and 0 unexposed library operations named filterWhile having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op filterWhile to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation. Cannot find a definition or applicable library operation named filterWhile with argument type(s) FunctionCalled(g) Variable(p)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need. FriCAS will attempt to step through and interpret the code. Compiled code for g has been cleared. Compiled code for lessTest has been cleared. 1 old definition(s) deleted for function or rule g
Compiling function g with type PositiveInteger -> Boolean true There are 2 exposed and 0 unexposed library operations named filterWhile having 2 argument(s) but none was determined to be applicable. Use HyperDoc Browse,or issue )display op filterWhile to learn more about the available operations. Perhaps package-calling the operation or using coercions on the arguments will allow you to apply the operation.
Cannot find a definition or applicable library operation named filterWhile with argument type(s) FunctionCalled(g) Variable(p)
Perhaps you should use "@" to indicate the required return type,or "$" to specify which version of the function you need.
This crashes:
\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
minor, since one has enough time to kill the evaluation using ctrl-c
It was a bug in the function macroexpandall. At that time the workaround was to compile functions via the system command)set function compile on
(we did not notice it here). I just tested this workaround in an old version of Axiom (February 2005) and it cures this issue. For information, an old version of Axiom (or a recent version with the buggy macroexpandall function) compiled on gcl-2.6.8pre does not crash but silently returns.
Status: open => closed