Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15117
| From | James Stein <mathgroup@stein.org> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Rather simple function returns curious result. |
| Date | 2013-07-03 08:53 +0000 |
| Message-ID | <kr0oq6$3f5$1@smc.vnet.net> (permalink) |
| References | <20130702044842.DB5BC6A5F@smc.vnet.net> <51D26ADF.5080802@tue.nl> |
| Organization | Time-Warner Telecom |
Dear Fred,
Thanks to you, and any others who respond.
Another case of proof-reader's blindness
when proof-reader and author are the same person.
I had indeed meant to write ___List, not List___,
and knowing what I meant, could not see what I wrote.
Chagrined, James
On Mon, Jul 1, 2013 at 10:53 PM, Fred Simons <f.h.simons@tue.nl> wrote:
> Hi James,
>
> The problem is in List___. In this way, you use the Mathematica name List
> as a dummy name for passing the arguments into the function body. If you
> use the correct syntax ___List (any number of arguments, all with head
> List), the problem is over.
>
> Regards,
>
> Fred Simons
> Eindhoven University of Technology
>
> Op 2-7-2013 6:48, James Stein schreef:
>
> 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 | Find similar | Unroll thread
Re: Rather simple function returns curious result. James Stein <mathgroup@stein.org> - 2013-07-03 08:53 +0000
csiph-web