Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ReplaceAll evaluation

8 views
Skip to first unread message

Rui

unread,
Oct 30, 2009, 3:18:29 AM10/30/09
to
I found myself writing Unevaluate[blabla..balbal] /. Rules way too
often. Most of the times I don't want the /. to evaluate it before
replacing.
Is there any nice way to do it?
Or I should set the attribute HoldFirst, or type that all the time, or
create my own function?
Thanks
Rui Rojo

Szabolcs Horvát

unread,
Oct 31, 2009, 2:51:37 AM10/31/09
to

Can you give some real examples where you use this construct?

Leonid Shifrin

unread,
Oct 31, 2009, 2:55:39 AM10/31/09
to
Hi Rui,

I would make my own function with a HoldFirst attribute.

ClearAll[replaceAllUnevaluated];
SetAttributes[replaceAllUnevaluated, HoldFirst];
replaceAllUnevaluated[expr_, rules_] := Unevaluated[expr] /. rules;


Regards,
Leonid

On Fri, Oct 30, 2009 at 10:18 AM, Rui <rui....@gmail.com> wrote:

> I found myself writing Unevaluate[blabla..balbal] /. Rules way too
> often. Most of the times I don't want the /. to evaluate it before
> replacing.
> Is there any nice way to do it?
> Or I should set the attribute HoldFirst, or type that all the time, or
> create my own function?

> Thanks
> Rui Rojo
>
>


Szabolcs Horvát

unread,
Oct 31, 2009, 3:28:58 AM10/31/09
to
On 2009.10.30. 8:18, Rui wrote:

Can you give some real examples where you use this construct?

Leonid Shifrin

unread,
Oct 31, 2009, 3:31:42 AM10/31/09
to
Hi Rui,

I would make my own function with a HoldFirst attribute.

ClearAll[replaceAllUnevaluated];
SetAttributes[replaceAllUnevaluated, HoldFirst];
replaceAllUnevaluated[expr_, rules_] := Unevaluated[expr] /. rules;


Regards,
Leonid

On Fri, Oct 30, 2009 at 10:18 AM, Rui <rui....@gmail.com> wrote:

> I found myself writing Unevaluate[blabla..balbal] /. Rules way too
> often. Most of the times I don't want the /. to evaluate it before
> replacing.
> Is there any nice way to do it?
> Or I should set the attribute HoldFirst, or type that all the time, or
> create my own function?

> Thanks
> Rui Rojo
>
>


0 new messages