Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Programmatically creating functions of many variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113659] Programmatically creating functions of many variables
  • From: Yaroslav Bulatov <yaroslavvb at gmail.com>
  • Date: Sat, 6 Nov 2010 05:01:03 -0500 (EST)

Suppose I have a graph, and I'd like to create a function which checks
whether given assignment of nodes is a proper labeling -- ie, no two
adjacent nodes get the same number. One could do something like the
following, but that gives Part warnings. Is there a preferred
approach?

graph = GraphData[{"Grid", {2, 2}}, "AdjacencyMatrix"] // Normal;
f = Function @@ {{x}, And @@ (x[[First[#]]] != x[[Last[#]]] & /@
Position[graph, 1])}

This is actually a problem that I periodically come across. Part
approach causes warnings meanwhile something like Function @@
{Subscript[x,#]&/@Range[n], ...} doesn't work. What are typical ways
of generating multivariate functions automatically?

----
Yaroslav
http://stackoverflow.com/users/419116/yaroslav-bulatov


  • Prev by Date: Re: Balance point of a solid
  • Next by Date: FFT in mathematica
  • Previous by thread: help: how to fit a list of data in two dimensions with an equation in
  • Next by thread: Re: Programmatically creating functions of many variables