aradi / fypp

Python powered Fortran preprocessor
http://fypp.readthedocs.io
BSD 2-Clause "Simplified" License
180 stars 30 forks source link

Document variadic arguments and recursive calls #22

Closed aradi closed 2 years ago

aradi commented 2 years ago

Improves documentation on variadic arguments and explicitly mentions recursive calls using the Horner-scheme as demonstration.

Closes #8 Closes #21

ivan-pi commented 2 years ago

In the Horner example it might be good to add another pair of brackets in case of negative coefficients:

  #:def horner(x, a, b, *args)
  #:set res = "({} * {} + ({}))".format(a, x, b)
  #:if len(args) > 0
    #:set res = horner(x, res, args[0], *args[1:])
  #:endif
    $:res
  #:enddef
aradi commented 2 years ago

Done (ead4ade), thanks!