RE: Returning an empty sequence
- To: mathgroup at smc.vnet.net
- Subject: [mg63301] RE: [mg63273] Returning an empty sequence
- From: "David Park" <djmp at earthlink.net>
- Date: Fri, 23 Dec 2005 05:08:26 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Trevor, Use Unevaluated. f[n_] := Switch[n, 1, "foo", 2, Unevaluated[Sequence[ ]], 3, {"bar"}]; f /@ {1, 2, 3} {foo, {bar}} David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ From: Trevor Baca [mailto:trevorbaca at gmail.com] To: mathgroup at smc.vnet.net 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.