login  home  contents  what's new  discussion  bug reports     help  links  subscribe  changes  refresh  edit

Edit detail for SandBoxOverloading revision 7 of 8

1 2 3 4 5 6 7 8
Editor: Bill Page
Time: 2008/05/22 11:09:45 GMT-7
Note: anonymous functions with unnamed arguments

added:
    bar8: () -> ((Integer,Integer) -> Integer)

added:
    bar8 == (#1 * #1) + (#2 * #2)

changed:
-bar8() == x +-> x + x
-bar8()(3)
bar7x() == x +-> x + x
bar7x()(3)
bar8()(3,4)
bar8x() == (x,y) +-> x*x + y*y
bar8x()(3,4)


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)
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/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 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 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)

fricas
bar(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)
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/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 SEC.
(time taken in buildFunctor: 0)
;;; *** |Aaa0| REDEFINED
;;; *** |Aaa0| REDEFINED Time: 0 SEC.
Cumulative Statistics for Constructor Aaa0 Time: 0 seconds
finalizing NRLIB AAA0 Processing Aaa0 for Browser database: --->-->Aaa0(constructor): Not documented!!!! --->-->Aaa0((bar0 ((Integer) (Integer)))): Not documented!!!! --->-->Aaa0((foo ((Integer) (Integer)))): Not documented!!!! --->-->Aaa0((foo ((Integer) (Float)))): Not documented!!!! --->-->Aaa0(): Missing Description ; compiling file "/var/aw/var/LatexWiki/AAA0.NRLIB/AAA0.lsp" (written 31 JUL 2013 04:47:33 PM):
; /var/aw/var/LatexWiki/AAA0.NRLIB/AAA0.fasl written ; compilation finished in 0:00:00.018 ------------------------------------------------------------------------ Aaa0 is now explicitly exposed in frame initial Aaa0 will be automatically loaded when needed from /var/aw/var/LatexWiki/AAA0.NRLIB/AAA0

fricas
bar0(3)

\label{eq1}3(1)
Type: PositiveInteger?

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)
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3603377070621137033-25px005.as
      using AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4: 
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier `Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3603377070621137033-25px005.as", line 5: bar2: Integer -> Integer ..........^.......^..^ [L5 C11] #9 (Error) No meaning for identifier `Integer'. [L5 C19] #10 (Error) There are no suitable meanings for the operator `->'. [L5 C22] #11 (Error) No meaning for identifier `Integer'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/3603377070621137033-25px005.as", line 13: bar2(z:Integer):Integer == foo(x)+foo(y) ...........^ [L13 C12] #12 (Error) No meaning for identifier `Integer'. [L13 C12] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

fricas
bar2(3)
There are no library operations named bar2 Use HyperDoc Browse or issue )what op bar2 to learn if there is any operation containing " bar2 " in its name.
Cannot find a definition or applicable library operation named bar2 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"
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)
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/2796111966566536169-25px007.as
      using AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4: 
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier `Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/2796111966566536169-25px007.as", line 5: bar3: Integer -> Integer ..........^.......^..^ [L5 C11] #9 (Error) No meaning for identifier `Integer'. [L5 C19] #10 (Error) There are no suitable meanings for the operator `->'. [L5 C22] #11 (Error) No meaning for identifier `Integer'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/2796111966566536169-25px007.as", line 13: bar3(z:Integer):Integer == foo(a)+foo(a) ...........^ [L13 C12] #12 (Error) No meaning for identifier `Integer'. [L13 C12] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

fricas
bar3(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)
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8356965697444416280-25px009.as
      using AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4: 
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier `Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8356965697444416280-25px009.as", line 5: bar4: Integer -> Integer ..........^.......^..^ [L5 C11] #9 (Error) No meaning for identifier `Integer'. [L5 C19] #10 (Error) There are no suitable meanings for the operator `->'. [L5 C22] #11 (Error) No meaning for identifier `Integer'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/8356965697444416280-25px009.as", line 13: bar4(z:Integer):Integer == foo(a@Integer)+foo(a@Float) ...........^ [L13 C12] #12 (Error) No meaning for identifier `Integer'. [L13 C12] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

fricas
bar4(4)
There are no library operations named bar4 Use HyperDoc Browse or issue )what op bar4 to learn if there is any operation containing " bar4 " in its name.
Cannot find a definition or applicable library operation named bar4 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.

calling functions with tuple --Bill Page, Thu, 22 May 2008 08:24:21 -0700 reply
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)
aldor
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7154599798421986088-25px011.as
      using AXIOM-XL compiler and options 
-O -Fasy -Fao -Flsp -laxiom -Mno-ALDOR_W_WillObsolete -DAxiom -Y $AXIOM/algebra -I $AXIOM/algebra
      Use the system command )set compiler args to change these 
      options.
#1 (Warning) Could not use archive file `libaxiom.al'.
#2 (Warning) Could not use archive file `libaxiom.al'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 4: 
import from AxiomLib;
............^
[L4 C13] #3 (Error) No meaning for identifier `AxiomLib'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 15: import { true: %, false: % } from Boolean; ..................................^ [L15 C35] #4 (Error) No meaning for identifier `Boolean'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 17: string: Literal -> %; ........................^.......^ [L17 C25] #5 (Error) No meaning for identifier `Literal'. [L17 C33] #6 (Error) There are no suitable meanings for the operator `->'.
"/usr/local/aldor/linux/1.1.0/include/axiom.as", line 18: } from String; .......^ [L18 C8] #8 (Error) No meaning for identifier `String'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7154599798421986088-25px011.as", line 5: bar5: Integer -> Integer ..........^.......^..^ [L5 C11] #9 (Error) No meaning for identifier `Integer'. [L5 C19] #10 (Error) There are no suitable meanings for the operator `->'. [L5 C22] #11 (Error) No meaning for identifier `Integer'.
"/var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/7154599798421986088-25px011.as", line 9: bar5(z:Integer):Integer == foo(1)+foo(1,2)+foo(1,2,3) ...........^ [L9 C12] #12 (Error) No meaning for identifier `Integer'. [L9 C12] #13 (Fatal Error) Too many errors (use `-M emax=n' or `-M no-emax' to change the limit).
The )library system command was not called after compilation.

fricas
bar5(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.

unnamed function arguments --Bill Page, Thu, 22 May 2008 10:26:36 -0700 reply
In SPAD a reference to #1, #2, in an expression denotes an anonymous function. E.g. #1 + #1 is the same as writing:

x +-> x + x

spad
)abbrev domain FFF Fff
Fff: with
    bar7: () -> (Integer -> Integer)
    bar8: () -> ((Integer,Integer) -> Integer)
  == add
    bar7 == #1 + #1
    bar8 == (#1 * #1) + (#2 * #2)
spad
   Compiling FriCAS source code from file 
      /var/lib/zope2.10/instance/axiom-wiki/var/LatexWiki/712240775020227376-25px013.spad
      using old system compiler.
   FFF abbreviates domain Fff 
------------------------------------------------------------------------
   initializing NRLIB FFF for Fff 
   compiling into NRLIB FFF 
   compiling exported bar7 : () -> Integer -> Integer
Time: 0 SEC.
compiling exported bar8 : () -> (Integer,Integer) -> Integer ****** comp fails at level 3 with expression: ****** error in function bar8
(+ (* |#1| |#1|) (* | << | (|#| 2) | >> | (|#| 2))) ****** level 3 ****** $x:= (# 2) $m:= $EmptyMode $f:= ((((|#2| #) (|#1| #) (|$Information| #) (|bar8| #) ...)))
>> Apparent user error: cannot compile (# 2)

fricas
bar7()(3)
There are no library operations named bar7 Use HyperDoc Browse or issue )what op bar7 to learn if there is any operation containing " bar7 " in its name.
Cannot find a no-argument definition or library operation named bar7 . bar7x() == x +-> x + x
Type: Void
fricas
bar7x()(3)
fricas
Compiling function bar7x with type () -> AnonymousFunction

\label{eq2}6(2)
Type: PositiveInteger?
fricas
bar8()(3,4)
There are no library operations named bar8 Use HyperDoc Browse or issue )what op bar8 to learn if there is any operation containing " bar8 " in its name.
Cannot find a no-argument definition or library operation named bar8 . bar8x() == (x,y) +-> x*x + y*y
Type: Void
fricas
bar8x()(3,4)
fricas
Compiling function bar8x with type () -> AnonymousFunction

\label{eq3}25(3)
Type: PositiveInteger?