I know that there are methods to structurally manipulate held expressions (discussed e.g. here), but I failed to apply those for this particular problem:
(Hold[{3, 4, 5 | 6}] /. (Verbatim@Alternatives)[x__] :> RandomChoice@List@x)
Hold[{3, 4, RandomChoice[{5, 6}]}]
The code should replace any Alternatives in the held expression with an appropriate choice from the alternatives, in this case either 5 or 6, i.e. it should evaluate the replacement.
HoldFirstis not a "held expression" wrapper, it's an attribute. – FJRA Mar 07 '12 at 02:08Holdrather thanHoldFirstorHoldRestorHoldAll(and deleted my previous comment before I saw your explanation) – kglr Mar 07 '12 at 02:14Verbatimis used in each answer? This will do too:/. x_Alternatives :> RuleCondition@RandomChoice@(List @@ x)or/. x_Alternatives :> With[{eval = RandomChoice@(List @@ x)}, eval /; True]). – Kuba Nov 22 '13 at 09:47Verbatimis only used becase I wanted to pass on arguments asSequence[5, 6]instead of5|6as in a replacement, the latter could possibly match more than one thing. It's not necessary but I guess they all tried to comply with my original specification. Your's is equally good. – István Zachar Nov 22 '13 at 09:59