Wolfram mathematica 只进行一次评估

Wolfram mathematica 只进行一次评估,wolfram-mathematica,Wolfram Mathematica,我正在寻找一种方法来定义一种模式,在这种模式中,现在不能完全评估定义 两个复杂问题:我不能简单地使用:=而不是=(我可以吗?),因为参数中的某些部分需要计算。我也没有成功地使用Hold(使用extract replace技巧来计算我的参数),因为这个Hold将永远存在-问题是我的模式还使用了另一个技巧,使得包含Hold的表达式实际上并不总是返回(当我明确地写下我的模式时,永远不会这样做,只有当其他一些函数在其中放入数字时才会这样做),因此我的ReleaseHold没有找到一个Hold,并且实际上

我正在寻找一种方法来定义一种模式,在这种模式中,现在不能完全评估定义

两个复杂问题:我不能简单地使用
:=
而不是
=
(我可以吗?),因为参数中的某些部分需要计算。我也没有成功地使用
Hold
(使用extract replace技巧来计算我的参数),因为这个
Hold
将永远存在-问题是我的模式还使用了另一个技巧,使得包含
Hold
的表达式实际上并不总是返回(当我明确地写下我的模式时,永远不会这样做,只有当其他一些函数在其中放入数字时才会这样做),因此我的
ReleaseHold
没有找到一个Hold,并且实际上消失了

我认为只有一次保持住的东西,而不是把头放在那里,可以救我。否则,一个不消失但放在那里的反保持头也会起作用,但不是那么好

这是我的代码,它只是试图求解n个参数的n个方程,但方程包含数值积分:

Do[
    (*make an array eq[k] of patterns that do nothing 
      if they dont get specific numbers in a list ak_ and otherwise do NIntegrate *) 
 eq[k] [ak_?  (Function[list, And @@ NumericQ /@ list]) ] = 
  (
   ReplacePart[#1, #2 -> Extract[#1, #2]] & [
         (*NIntegrate needs to be Holded, but the Do-loop-k must be plugged in inside
           its argument, so extract it and put it back*)                            
    Hold[ NIntegrate[complicated functions for each k with appearance of ak[[k]]), {t, 0, l}, 
      MaxRecursion -> 50] ]
                                      ,  { 1, 1}    
     ]
   )
 , {k, n}] 

(*test*)
ReleaseHold[eq[3][{2,4,3,5,2}]] (*gives a number, great! (n=5 here) *)

eqns = Table[ReleaseHold[eq[i][ Table[a[j], {j, n}]]], {i, n}]  (*does not give an error since pattern is not evaluated, great!*)

vars = Table[{a[i],0},{i,n}]
FindRoot[eqns,vars]
         (*does not work since there is still 
          the Hold appearing now, ReleaseHold above was useless 
          since pattern was not evaluated and Hold not appearing*) 

很抱歉代码标签弄乱了,我看不出这里发生了什么…在“Do”之后应该是一个代码块。也许尝试
Defer
Evaluate
而不是
Hold
ReleaseHold
。似乎不起作用……甚至“gives-a-number-test行”也没有计算成一个数字