MathGroup Archive 1995

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

Search the Archive

Re: Re: Puzzle

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2433] Re: [mg2419] Re: [mg2258] Puzzle
  • From: jpk at apex.mpe.FTA-Berlin.de (Jens-Peer Kuska)
  • Date: Wed, 8 Nov 1995 23:42:25 -0500

Partick Jemmer wrotes:

> 
> In trying to tidy this up, I attempted:
> 
> lst={6, 44, 30, 15, 24, 12, 33, 23, 18}
> chk={a___, b_, c___, d_, e___, f_, g___, h_, i___}
> cnd=b + d + f + h == 100
> sln={b,d,f,h}
> 
> lst/.chk/;cnd->sln
> 
> But this doesn't work...
> 
> nor does:
> 
> chk1=chk/;cnd
> 
> lst/.chk1->sln
> 
> nor does
> 
> chk2=Hold[chk/;cnd]
> 
> lst/.ReleaseHold[chk2]->sln
> 
> Any ideas to help sort out my confusion??
> 
> Cheers, patrick.
> 
> 
> 
Hi Patrick,

here is the solution

lst={6,44,30,15,24,12,33,23,18};
patt={a___,b_,c___,d_,e___,f_,g___,h_,i___};
cond= b+d+f+h==100;


(* The problem is that : *)

Attributes[Condition]


{HoldAll, Protected}

(* use  *)
lst /. Rule[Condition[Evaluate[patt],Evaluate[cond]],{b,d,f,h}]

(* and it works as expected *)

{44, 15, 23, 18}

Jens


  • Prev by Date: Re: Help on Infinite Series
  • Next by Date: Re: 3D Cluster Detection
  • Previous by thread: Re: Re: Puzzle
  • Next by thread: Re:Puzzle