Re: Returning an empty sequence
- To: mathgroup at smc.vnet.net
- Subject: [mg63291] Re: [mg63273] Returning an empty sequence
- From: Kristjan Kannike <kkannike at physic.ut.ee>
- Date: Fri, 23 Dec 2005 05:08:18 -0500 (EST)
- References: <200512220504.AAA05673@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hello!
Use
f[n_] := Switch[n, 1, "foo", 2, Unevaluated[Sequence[]], 3, {"bar"}] //
Evaluate;
On Thu, 22 Dec 2005, Trevor Baca wrote:
> What's the right way to have an expression evaluate to an empty
> sequence?
>
> I'd like ...
>
> f[n_] :=
> Switch[n,
> 1, "foo",
> 2, Sequence[ ],
> 3, {"bar"}];
>
> ... to work, but instead I get the message
>
> Switch::"argct": "Switch called with 6 arguments. Switch must be called
> with an odd number of arguments."
>
> meaning that the Sequence[ ] is flattened in the rhs definition of f[
> ].
>
> Is there a way to get f[ ] to evaluate to the empty Sequence[ ] (rather
> than Null)?
>
> Trevor.
>
Kristjan
<http://www.physic.ut.ee/~kkannike/>
"O Senhor é descrente?" You're an unbeliever?
"Só descredo no incrivel." I only disbelieve the unbelievable.
-- Orson Scott Card, Speaker for the Dead
- References:
- Returning an empty sequence
- From: "Trevor Baca" <trevorbaca@gmail.com>
- Returning an empty sequence