|
|
last edited 11 years ago by test1 |
1 2 3 4 5 6 7 8 | ||
Editor: Bill Page
Time: 2008/05/22 08:24:22 GMT-7 |
||
Note: calling functions with tuple |
added:
From BillPage Thu May 22 08:24:21 -0700 2008
From: Bill Page
Date: Thu, 22 May 2008 08:24:21 -0700
Subject: calling functions with tuple
Message-ID: <20080522082421-0700@axiom-wiki.newsynthesis.org>
\begin{aldor}
#pile
#include "axiom"
Eee: with
bar5: Integer -> Integer
== add
foo(x:Tuple Integer):Integer == 1
foo(x:Integer,y:Integer):Integer == 2
bar5(z:Integer):Integer == foo(1)+foo(1,2)+foo(1,2,3)
\end{aldor}
\begin{axiom}
bar5(1)
\end{axiom}
This fails in SPAD:
spad)abbrev domain AAA Aaa Aaa: with bar: Integer -> Integer == add foo(x:Float):Integer == 1 foo(x:Integer):Integer == 2 a:Integer == 1 a:Float == 1.0 x:Integer := 1 y:Float := 1.0 bar(z:Integer):Integer == foo(x)+foo(y)
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/162293060307836856-25px001.spad using old system compiler. AAA abbreviates domain Aaa ------------------------------------------------------------------------ initializing NRLIB AAA for Aaa compiling into NRLIB AAA compiling local foo : Float -> Integer AAA;foo is replaced by 1 Time: 0.06 SEC. compiling local foo : Integer -> Integer AAA;foo is replaced by 2 Time: 0 SEC. compiling local a : () -> Integer AAA;a is replaced by 1 Time: 0 SEC. compiling local a : () -> Float Time: 0.01 SEC. compiling exported bar : Integer -> Integer ****** comp fails at level 3 with expression: ****** error in function bar (+ (|foo| |x|) (|foo| | << y >> |)) ****** level 3 ****** $x:= y $m:= (Integer) $f:= ((((|z| # #) (|y| # #) (* # # #) (** # # #) ...) ((|foo| #)) ((|foo| #) (* # # #) (** # # #) (+ # #) ...))) >> Apparent user error: Cannot coerce y of mode (Float) to mode (Integer)
axiombar(3) There are no library operations named bar Use HyperDoc Browse or issue )what op bar to learn if there is any operation containing " bar " in its name. Cannot find a definition or applicable library operation named bar with argument type(s) PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.
spad)abbrev domain AAA0 Aaa0 Aaa0: with bar0: Integer -> Integer foo: Integer -> Integer foo: Float -> Integer == add foo(x:Float):Integer == 1 foo(x:Integer):Integer == 2 x:Integer := 1 y:Float := 1.0 bar0(z:Integer):Integer == foo(x)+foo(y)
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/6395014362195898863-25px003.spad using old system compiler. AAA0 abbreviates domain Aaa0 ------------------------------------------------------------------------ initializing NRLIB AAA0 for Aaa0 compiling into NRLIB AAA0 compiling exported foo : Float -> Integer AAA0;foo;FI;1 is replaced by 1 Time: 0 SEC. compiling exported foo : Integer -> Integer AAA0;foo;2I;2 is replaced by 2 Time: 0 SEC. compiling exported bar0 : Integer -> Integer Time: 0.01 SEC. (time taken in buildFunctor: 0) ;;; *** |Aaa0| REDEFINED ;;; *** |Aaa0| REDEFINED Time: 0 SEC. Cumulative Statistics for Constructor Aaa0 Time: 0.01 seconds finalizing NRLIB AAA0 Processing Aaa0 for Browser database: --->-->Aaa0((bar0 ((Integer) (Integer)))): Not documented!!!! --->-->Aaa0((foo ((Integer) (Integer)))): Not documented!!!! --->-->Aaa0((foo ((Integer) (Float)))): Not documented!!!! --->-->Aaa0(constructor): Not documented!!!! --->-->Aaa0(): Missing Description ------------------------------------------------------------------------ Aaa0 is now explicitly exposed in frame initial Aaa0 will be automatically loaded when needed from /var/zope2/var/LatexWiki/AAA0.NRLIB/code
axiombar0(3)
(1) |
But it works in Aldor:
aldor#pile #include "axiom" Bbb: with bar2: Integer -> Integer == add foo(x:Float):Integer == 1 foo(x:Integer):Integer == 2 a:Integer == 1 a:Float == 1.0 x:Integer := 1 y:Float := 1.0 bar2(z:Integer):Integer == foo(x)+foo(y)
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/3603377070621137033-25px005.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra Use the system command )set compiler args to change these options. #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL' Compiling Lisp source code from file ./3603377070621137033-25px005.lsp Issuing )library command for 3603377070621137033-25px005 Reading /var/zope2/var/LatexWiki/3603377070621137033-25px005.asy Bbb is now explicitly exposed in frame initial Bbb will be automatically loaded when needed from /var/zope2/var/LatexWiki/3603377070621137033-25px005
axiombar2(3)
(2) |
aldor#pile #include "axiom" Ccc: with bar3: Integer -> Integer == add foo(x:Float):Integer == 1 foo(x:Integer):Integer == 2 a:Integer == 1 a:Float == 1.0 x:Integer := 1 y:Float := 1.0 bar3(z:Integer):Integer == foo(a)+foo(a)
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/2796111966566536169-25px007.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra Use the system command )set compiler args to change these options. #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL' "/var/zope2/var/LatexWiki/2796111966566536169-25px007.as", line 13: bar3(z:Integer):Integer == foo(a)+foo(a) ...............................^......^ [L13 C32] #2 (Error) There are 2 meanings for the operator `foo'. Meaning 1: (x: Float) -> Integer Meaning 2: (x: Integer) -> Integer The )library system command was not called after compilation.
axiombar3(3) There are no library operations named bar3 Use HyperDoc Browse or issue )what op bar3 to learn if there is any operation containing " bar3 " in its name. Cannot find a definition or applicable library operation named bar3 with argument type(s) PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.
aldor#pile #include "axiom" Ddd: with bar4: Integer -> Integer == add foo(x:Float):Integer == 1 foo(x:Integer):Integer == 2 a:Integer == 1 a:Float == 1.0 x:Integer := 1 y:Float := 1.0 bar4(z:Integer):Integer == foo(a@Integer)+foo(a@Float)
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/8356965697444416280-25px009.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra Use the system command )set compiler args to change these options. #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL' Compiling Lisp source code from file ./8356965697444416280-25px009.lsp Issuing )library command for 8356965697444416280-25px009 Reading /var/zope2/var/LatexWiki/8356965697444416280-25px009.asy Ddd is now explicitly exposed in frame initial Ddd will be automatically loaded when needed from /var/zope2/var/LatexWiki/8356965697444416280-25px009
axiombar4(4)
(3) |
aldor#pile #include "axiom" Eee: with bar5: Integer -> Integer == add foo(x:Tuple Integer):Integer == 1 foo(x:Integer,y:Integer):Integer == 2 bar5(z:Integer):Integer == foo(1)+foo(1,2)+foo(1,2,3)
Compiling FriCAS source code from file /var/zope2/var/LatexWiki/7154599798421986088-25px001.as using AXIOM-XL compiler and options -O -Fasy -Fao -Flsp -laxiom -Mno-AXL_W_WillObsolete -DAxiom -Y $AXIOM/algebra Use the system command )set compiler args to change these options. #1 (Warning) Deprecated message prefix: use `ALDOR_' instead of `_AXL' "/var/zope2/var/LatexWiki/7154599798421986088-25px001.as", line 9: bar5(z:Integer):Integer == foo(1)+foo(1,2)+foo(1,2,3) ......................................^ [L9 C39] #2 (Error) There are 2 meanings for the operator `foo'. Meaning 1: (x: Tuple(Integer)) -> Integer Meaning 2: (x: Integer, y: Integer) -> Integer The )library system command was not called after compilation.
axiombar5(1) There are no library operations named bar5 Use HyperDoc Browse or issue )what op bar5 to learn if there is any operation containing " bar5 " in its name. Cannot find a definition or applicable library operation named bar5 with argument type(s) PositiveInteger Perhaps you should use "@" to indicate the required return type, or "$" to specify which version of the function you need.