#79 Improve pattern matching

open
nobody
None
5
2012-11-18
2010-03-23
Anonymous
No

I would like to define patterns that match with variable argument number functions, like patterns "__" and "___" in wolfram's mathematica:

f[a_,b___,c_] match with
f[r,s]
f[r,q,s]
f[r,q,w,s]

Sadly, gnu maxima has no way to instruct to its simplifier this kind of rules

Best Regards
M

Discussion


  • Anonymous
    2010-05-25

    I am not familiar with Mathematica (it's been 15 years...), but Maxima does allow you to define a function that takes a variable number of arguments, viz.

    f(x,[y]) := ....

    then

    f(a) --> x=a, y=[]
    f(a,b) --> x=a,y=[b]
    f(a,b,c) --> x=a,y=[b,c], etc.

     
    Last edit: Anonymous 2014-07-28