I have some problems when I try to have high order generic functions in Fricas:
For example, 'plus' is a high order generic functions that takes two functions
(f,g) and returns an (anonymous) function (with parameter x) that returns the
sum of f(x) and g(x) :
1. Do it in REPL:
plus (f,g) == x+->f(x)+g(x)
Test it:
double n == n + n
h := plus(double,double)
h 4
but get:
FriCAS will attempt to step through and interpret the code.
Anonymous user functions created with +-> that are processed in
interpret-code mode must have result target information
available. This information is not present so FriCAS cannot
proceed any further. This may be remedied by declaring the
function.
2. Do it in Spad:
-- file plus.spad starts here
)abbrev package PLSPKG PlusPackage
PlusPackage(A:SetCategory, B:AbelianSemiGroup) : Exports == Impl where
Exports == with
plus2 : ((A->B),(A->B))->(A->B)
Impl == add
plus2(f,g) == x+->f(x)+g(x)
)abbrev package TEST1 TestPlusPackage
TestPlusPackage(A:AbelianSemiGroup) : Exports == Impl where
Exports == with
double2 : A->A
Impl == add
double2 x == x+x
-- file plus.spad ends here
and in REPL:
)compile plus
h == plus2(double2,double2)
h 4
but get:
There are 1 exposed and 0 unexposed library operations named plus2
having 2 argument(s) but none was determined to be applicable.
What/Where is going wrong?
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.