       Re: Whitespace weirdness.

• To: mathgroup at smc.vnet.net
• Subject: [mg74382] Re: Whitespace weirdness.
• From: "Jean-Marc Gulliet" <jeanmarc.gulliet at gmail.com>
• Date: Mon, 19 Mar 2007 21:59:42 -0500 (EST)
• References: <BAY135-F10BABD11C097B92A5D3A88C0760@phx.gbl>

```On 3/19/07, wooks . <wookiz at hotmail.com> wrote:
>
> >From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
> >To: wooks <wookiz at hotmail.com>,  mathgroup at smc.vnet.net
> >Subject: Re: Whitespace weirdness.
> >Date: Mon, 19 Mar 2007 11:59:16 +0100
> >
> >wooks wrote:
> >>Clear[Eternity,x];
> >>Eternity[x_]:=Eternity[x];
> >
> >Totally buggy function definition for his definition leads to infinite
> >recursion.
> >
>
> It's intentional. It's building up to the halting problem.

OK, I see. I stand corrected.

> >>Clear[EmptyQ];
> >>EmptyQ[{}] := True;
> >>EmptyQ[x_List] := False;
> >>EmptyQ[x_] := Print["Argument to EmptyQ must be a list."];
> >>
> >>Clear[length,list,f,g]
> >>Function[f,
> >>     Function[list,If[EmptyQ[list],0,
> >>                                             1+f[Rest[list]]]]]
> >>
> >>[Function[g,
> > >
> >>Function[list,If[EmptyQ[list], 0,
> >>                                                                 1 +
> >>g[Rest[list]]]]][Eternity]]
> >>
> >>Clear[length,list,f,g]
> >>Function[f,
> >>   Function[list,If[EmptyQ[list],0,
> >>                                           1+f[Rest[list]]]]]
> >>[Function[g,Function[list,If[EmptyQ[list], 0,
> >==^
> >Funny extra open square bracket.
> >
>
> It's not extra

Looking at the notebook you sent me, I realized that this code is
valid (when I copied the code from Usenet, Mathematica complained

>                                              1 +
> >>g[Rest[list]]]]][Eternity]]
> >=================^=^^^^^^^^
> >Missing open square bracket.
> >The symbol Eternity is not defined. Maybe you wanted Eternity[x]?
> >
> >>  Here are 2 versions of the same anonymous function. The only
> >>difference between them is that in the second version Function[g....
> >>starts on a new line.
> >
> >No. See my comments above.
> >
> >>One of them works.
> >
> >No. As written above, none of them work, and none of them can work.
> >
>
> The first does work. The second doesn't.
>
> >>The other generates a syntax error.
> >

OK. I get that with the attached notebook.

> >You should post the code and some tests with their exact results and
> >associated error/warning messages directly copied (preferably in InputFo=
rm)
> >from a fresh Mathematica session. For instance,
> >
>
> I've attached a notebook. I wll try to update the post on the newsgroup
> later.

Here is the results before and after the modification between line 4 and 5.

In:=
Clear[Eternity,x];
Eternity[x_]:=Eternity[x];

In:=
Clear[EmptyQ];
EmptyQ[{}]:=True;
EmptyQ[x_List]:=False;
EmptyQ[x_]:=Print["Argument to EmptyQ must be a list."];

Also check this

In:=
Clear[length,list,f,g]
Function[f,
Function[list,If[EmptyQ[list],0,
1+f[Rest[list]]]]][
Function[g,Function[list,If[EmptyQ[list], 0,

1 + g[Rest[list]]]]][Eternity]][{a}]

Out=
1

Now try moving the square bracket at the end of the 4th line to the
beginning of the 5th line.

In:=
Clear[length,list,f,g]
Function[f,
Function[list,If[EmptyQ[list],0,
1+f[Rest[list]]]]]
[Function[g,Function[list,If[EmptyQ[list], 0,

1 + g[Rest[list]]]]][Eternity]]

Out=
Function[f,Function[list,If[EmptyQ[list],0,1+f[Rest[list]]]]]

>From In:=
\!\(\*
RowBox[{\(Syntax::"tsntxi"\), \(\(:\)\(\ \)\), "\<\"\\\"\\!\\([\\(\\(\\(\=
\(
Function[\\(\\(g, \\(\\(
Function[\\(\\(list, \\(\\(If[\\(\\(\[LeftSkeleton] 1 \
\[RightSkeleton]\\)\\)]\\)\\)\\)\\)]\\)\\)\\)\\)]\\)\\)[Eternity]\\)\\)]\\)=
\\\
\" is incomplete; more input is needed.\\!\\(\\\"\\\"\\) \
\
ButtonFrame->None, ButtonData:>\\\"General::tsntxi\\\"]\\)\"\>"}]\)

>From In:=
[Function[g,Function[list,If[EmptyQ[list],0,1+g[Rest[list]]]]][Eternity]]

Below, I did the modification between line 4 and 5, and the issue is
solved. Though, I have not idea why.

In:=
Clear[Eternity,x];
Eternity[x_]:=Eternity[x];

In:=
Clear[EmptyQ];
EmptyQ[{}]:=True;
EmptyQ[x_List]:=False;
EmptyQ[x_]:=Print["Argument to EmptyQ must be a list."];

Also check this

In:=
Clear[length,list,f,g]
Function[f,
Function[list,If[EmptyQ[list],0,
1+f[Rest[list]]]]][
Function[g,Function[list,If[EmptyQ[list], 0,

1 + g[Rest[list]]]]][Eternity]][{a}]

Out=
1

Now try moving the square bracket at the end of the 4th line to the
beginning of the 5th line.

In:=
Clear[length,list,f,g]
Function[f,
Function[list,If[EmptyQ[list],0,
1+f[Rest[list]]]]
][Function[g,Function[list,If[EmptyQ[list], 0,

1 + g[Rest[list]]]]][Eternity]]

Out=
Function[list\$,If[EmptyQ[list\$],0,1+Function[list\$,If[EmptyQ[list\$],
0,1+Eternity[Rest[list\$]]]][Rest[list\$]]]]

Regards,
Jean-Marc

```

• Prev by Date: Re: Normal for Limit : Example
• Next by Date: Re: Possible bug in NSolve[equation, variable, precission]
• Previous by thread: Re: Whitespace weirdness.
• Next by thread: Normal for Limit : Example