Linked Questions

1 vote
0 answers

Find the arity of any function [duplicate]

First an example: f[x_,y_]:=x+y would have arity 2 because it takes 2 inputs while the function g[x]:=0 has arity 1, even though ...
Nada F.'s user avatar
  • 71
596 votes
19 answers

Where can I find examples of good Mathematica programming practice?

I consider myself a pretty good Mathematica programmer, but I'm always looking out for ways to either improve my way of doing things in Mathematica, or to see if there's something nifty that I haven't ...
92 votes
4 answers

Automatically generating a dependency graph of an arbitrary Mathematica function?

Has anyone written a function to pull the function dependencies of a function? That is, it would be nice to have a function that returns a list of function dependencies as a set of rules, terminating ...
berniethejet's user avatar
  • 1,407
40 votes
1 answer

What can I use as the second argument to Return in my own functions?

Having found out about the second argument to Return I played a bit with it, and the following tests all resulted in ...
celtschk's user avatar
  • 19.1k
8 votes
4 answers

How can I get the number of slots in Function?

Suppose that I define f = Function[#1 + #2]; And I want to define a new function, argsNum, so that it returns a number of ...
Analysis's user avatar
  • 369
11 votes
5 answers

How to get the parameter number of inbuilt function

I want to make a custom function parameterNumber,which can return the parameter number of inbuilt function,as the Plot's ...
yode's user avatar
  • 26.1k
11 votes
3 answers

How to write a function-defining function which stores the function arguments in a stack?

I have a function-defining function SetAttributes[DefFn, HoldAll]; DefFn[f_[args___], body_] := f[args] := body; I am trying to modify this function to record ...
Ian Hinder's user avatar
  • 2,125
4 votes
5 answers

Using Through with SlotSequence

I have an expression consisting of a few pure functions added together like so: f+g+h I want to add the bodies of these functions together and make that a pure ...
Myridium's user avatar
  • 1,089
9 votes
1 answer

Automatization of SyntaxInformation and argx?

Does anybody have a good way to automate the setting of SyntaxInformation for any custom function? I have a ton of functions for which I want to set SyntaxInformation, and doing it by hand seems a ...
Teake Nutma's user avatar
  • 5,971
2 votes
1 answer

How many arguments does a function require, and how to use that in `Manipulate`

The goal is to vary the order parameters in wavelet transforms in the Manipulate environment. The various transformations have arguments of different rank. For ...
dantopa's user avatar
  • 1,010
0 votes
1 answer

Create jacobian Function from a vector Function

This is related to this question and maybe this question. I wanted a function that takes an n-parameter vector function and outputs a Jacobian matrix function, also n-parameter. I think this works: <...
user6552's user avatar
  • 341
5 votes
1 answer

Meta information about function parameters

I'm working on a project that allows for executing arbitrary, user-defined Mathematica scripts. It's an internal tool running on a trusted, local network. It's basically a web interface to Mathematica....
isanae's user avatar
  • 153
2 votes
1 answer

Examine function parameters programmatically

I write a lot of scripts in Mathematica and I'd like to eliminate the boilerplate that parses command-line arguments and assigns them to variables of the correct type before doing the real work. I was ...
Ashley's user avatar
  • 269
1 vote
0 answers

Pattern for a function of say 2 variables [closed]

How can I specify a pattern for an expression f for which say f[x,y] returns a value, ie is defined as a function taking two ...
Shb's user avatar
  • 701