On Thu, Jul 23, 2009 at 4:57 PM, Waldek Hebisch wrote:
>
> Bill Page wrote:
>>
>> Why does FriCAS print "n=13" in the following simple example of
>> a nested function in the interpreter? There is no assignment to n.
>>
>> (1) -> )r test3.input
>> gpp (p,n) ==
>> -- nested function
>> g(x,r,m,c) ==
>> output("c=",c)
>> output("n=",n)
>> output("m=",m)
>> if c = m then r else g(x-1,r*x,m,c+1)
>> output("p=",p)
>> output("n=",n)
>> g(p,1,n,0)
>>
>> Type: Void
>> -- test
>> gpp(13,1)
>>
>> Compiling function g with type (Integer,Integer,Integer,Integer) ->
>> Integer
>> Compiling function gpp with type (PositiveInteger,PositiveInteger)
>> -> Integer
>> p= 13
>> n= 1
>> c= 0
>> n= 1
>> m= 1
>> c= 1
>> n= 13
>> m= 1
>>
>> (2) 13
>
> To get value of n the g function fetches second argument. But instead
> of fetching second argument to gpp it fetches its own second argument...
>
I hope you agree that this behavior is incorrect?
Do you think nested functions should be disallowed or is this bug not
so difficult to fix?
Regards,
Bill Page.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---