Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #15102 > unrolled thread
| Started by | Fred Simons <f.h.simons@tue.nl> |
|---|---|
| First post | 2013-07-03 08:45 +0000 |
| Last post | 2013-07-03 08:45 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Rather simple function returns curious result. Explanation Fred Simons <f.h.simons@tue.nl> - 2013-07-03 08:45 +0000
| From | Fred Simons <f.h.simons@tue.nl> |
|---|---|
| Date | 2013-07-03 08:45 +0000 |
| Subject | Re: Rather simple function returns curious result. Explanation |
| Message-ID | <kr0oc7$3d4$1@smc.vnet.net> |
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 top | Article view | comp.soft-sys.math.mathematica
csiph-web