RHERWOLF

62 Reputation

4 Badges

9 years, 156 days

MaplePrimes Activity


These are replies submitted by RHERWOLF

Interesting. What about that? It makes procedure using code of other procedure, ordered parameters list, keyword parameters set and boolean "optimize". If no bugs in code we can find here and use when we need it.

BuildProc := proc(p::procedure, a::list, k::set := {}, o::truefalse := true) local t::nothing;
    if o then
        seq(ToInert(piecewise(type(t, `=`), lhs(t), t)), t in a), seq(ToInert(lhs(t)), t in k);
        codegen['optimize'](FromInert(_Inert_PROC(_Inert_PARAMSEQ(%), op(2 .., ToInert(p)))), 'tryhard')
    else p end if;
    seq(piecewise(type(t, `=`), _Inert_ASSIGN(ToInert(lhs(t)), ToInert(rhs(t))), ToInert(t)), t in a);
    _Inert_SET(_Inert_EXPSEQ(seq(_Inert_ASSIGN(ToInert(lhs(t)), ToInert(rhs(t))), t in k)));
    return FromInert(_Inert_PROC(_Inert_PARAMSEQ(%%, %), op(2 .., ToInert(%%%))))
end proc


The "cat" procedure concatenates symbols, strings, etc. Result is of same type of first argument. You can use "indets" procedure to find expression variables set and "diff" to get derivative of expression at a variable.

The "PutDelta" concatenates empty symbol (result is symbol), delta string (delta symbol does errors in some cases) and argument (expected symbol "a" with no value). The "Diffs" sums for each temporary symbol in expression the product of temporary infinitesimal and derivative of expression at temporary variable.

Page 1 of 1