Help with conditional rules
- To: mathgroup at christensen.Cybernetics.NET (mathgroup )
- Subject: Help with conditional rules
- From: leboeuf at ere.umontreal.ca (Leboeuf Martin)
- Date: Tue, 25 Oct 1994 13:58:57 -0400 (EDT)
Hello mathgroupers, Let me first thank Steve for his excellent work with mathgroup, and I can only be forever thankfull to him for maintaining such a valuable forum. Here is now my problem. I generate functions of the type: FUNC[2,2,2,0,3,1] In other words, functions all with the same Head FUNC and with 6 Integer arguments. Now, depending upon the value of those arguments, I want to substitute the Head. For example: FUNC[2,2,2,0,3,1] /. FUNC :> F1 /; FUNC[2,2,2,0,3,1][[1]] + FUNC[2,2,2,0,3,1][[2]] + FUNC[2,2,2,0,3,1][[3]] == 6 and I get: F1[2,2,2,0,3,1] which would be OK for me. But I have hundreds of FUNC's, so I would like the above rule to work for any given FUNC. I tried FUNC[2,2,2,0,3,1] /. FUNC :> F1 /; FUNC[i_,j_,k_,l_,m_,n_][[1]] + FUNC[i_,j_,k_,l_,m_,n_][[2]] + FUNC[i_,j_,k_,l_,m_,n_][[3]] == 6 and other similar things, but obviously without success. To be more general, how can one define a rule (or whatever) to extract the nth argument of a function with a fixed (or undefined) number of arguments? Thanx, martin leboeuf at ere.umontreal.ca