Yrogirg wrote:
> 
> I have some problems with blocks. Maybe I don't get them right.
> 
> MyFunc : Float -> Float
> MyFunc x ==
>     a : Integer -> Float
>     a i == x^i
>     reduce(+, map(a, [0,1,2,3,4]))
> 
> I expect the result of MyFunct 0.1 to be 0.1^0+0.1^1+0.1^2+0.1^3+0.1^4
> = 1.1111
> 
> However MyFunc can't be even compiled:
> 
>    Compiling function MyFunc with type Float -> Float
> 
>  [1]  signature:   FLOAT -> FLOAT
>       implemented: local function *1;MyFunc;1;frame1
> 
> 
>    >> System error:
>    The value UNINITIALIZED_VARIABLE is not of type LIST.
> 


Actually, MyFunc got miscomplied and crashed during evaluation.
You do not have problem with blocks.  The problem is with
local functions: I would say that local functions using '=='
notation are not supported in the interpreter (they work
in the Spad compiler).  Your example can be rewritten in
the following way:

MyFunc : Float -> Float
MyFunc x ==
    a : Integer -> Float := i +-> x^i
    reduce(+, map(a, [0,1,2,3,4]))


that is using '+->' notation to create anonymous function and
assigning this function to 'a'.  Examples like this do not
need separate function and can be written as:

MyFunc x ==
    reduce(+, map(i +-> x^i, [0,1,2,3,4]))


-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to