Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15088
| From | James Stein <mathgroup@stein.org> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Rather simple function returns curious result. Explanation requested. |
| Date | 2013-07-02 04:34 +0000 |
| Message-ID | <kqtl8l$ath$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
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
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Rather simple function returns curious result. Explanation requested. James Stein <mathgroup@stein.org> - 2013-07-02 04:34 +0000 Re: Rather simple function returns curious result. Explanation requested. "Nasser M. Abbasi" <nma@12000.org> - 2013-07-03 08:51 +0000
csiph-web