Rather simple function returns curious result. Explanation requested.
- To: mathgroup at smc.vnet.net
 - Subject: [mg131384] Rather simple function returns curious result. Explanation requested.
 - From: James Stein <mathgroup at stein.org>
 - Date: Tue, 2 Jul 2013 00:48:42 -0400 (EDT)
 - Delivered-to: l-mathgroup@mail-archive0.wolfram.com
 - Delivered-to: l-mathgroup@wolfram.com
 - Delivered-to: mathgroup-outx@smc.vnet.net
 - Delivered-to: mathgroup-newsendx@smc.vnet.net
 
For reasons that escape me, the simple function below fails to return
an empty List when n==2; Is this a bug? If not, what is the
explanation? If the return value for n==2 is changed to an integer or
a string, the function behaves as expected.(Of course, this bizarre
function is the result of simplifying a more reasonable one.)
Clear[ f ];
f [run : { List___ } ] := Module [ { n },
   n = run // Length;
   If [ n != 2, Return [ n ] ];
   Module [ { } ,
    { } (* Return Empty List if n==2 *)
    ]
   ] ;
f [ { } ]
f [ { { } } ]
f [ { { }, { } } ]
f [ { { }, { }, { } } ]
f [ { { }, { }, { }, { } } ]
When I run the above, I get these four outputs:
0
1
Sequence[{}, {}][]
3
4
- Follow-Ups:
- Re: Rather simple function returns curious result.
- From: Bob Hanlon <hanlonr357@gmail.com>
 
 - Re: Rather simple function returns curious result. Explanation
- From: Fred Simons <f.h.simons@tue.nl>
 
 
 - Re: Rather simple function returns curious result.