On Mon, Oct 26, 2009 at 11:02 PM, Waldek Hebisch wrote: > >> Martin wrote: >> > >> > unparse((2*product(factorial i, i=0..n))::OUTFORM::INFORM) >> > >> > makes fricas crash... >> > > The crash was due to spurious line that from the rewrite time. > And it crashed on legal input too... >
Thanks for finding the problem! Bill Page wrote: >> I guess it's no excuse for a break condition but I presume you >> intended to write: >> >> (11) -> unparse((2*product(factorial i, i=0..n))::INFORM) >> >> (11) "2*%defprod(factorial(%A),%A,i,0,n)" >> Type: String > Another question is what we should generate for products, > sums and integrals. The current result is _not_ valid as input... > Yes, that is an important point. Considering just product for the moment, I took a quite look at the code in 'combfunc.spad.pamphlet'. It seems that what one might like to produce as a general InputForm in this case is opdprod(factorial(%A),%A,i,0,n) but 'opdprod' is not exported by 'CombinatorialFunction'. We do have opdprod := operator('%defprod)$CommonOperators evaluate(opdprod, iidprod) iidprod l == (r1:=retractIfCan(fourth l)@Union(Z,"failed")) case "failed" or (r2:=retractIfCan(fourth rest l)@Union(Z,"failed")) case "failed" or (k:=retractIfCan(second l)@Union(K,"failed")) case "failed" => idprod l */[eval(first l,k::K,i::F) for i in r1::Z .. r2::Z] and of course 'iidprod' is exported so we can write: (5) -> iidprod([factorial(%A),%A,i,0,n])$CombinatorialFunction(INT,EXPR INT) n ++-++ (5) | | i! | | i = 0 Type: Expression(Integer) Really I suppose it would make sense to make the operators such as 'opdprod' available for this purpose and define opdprod := operator('opdprod)$CommonOperators But watch out for infinite loops here! I was not able to locate any explicit code for coercion to InputForm. Did I just miss it? If not I presume that the coercion is done via OutputForm as Martin's original example may have implied: setProperty(opdprod, SPECIALDISP, ddprod@(List F -> O) pretend None) ddprod l == prod(summand(l)::O, third(l)::O = fourth(l)::O, fourth(rest l)::O) Do you see any other way? It seems that Martin re-wrote major parts of this pamphlet file. I hope he has time to take a look at this. 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 fricas-devel@googlegroups.com To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en -~----------~----~----~----~------~----~------~--~---