Eiffel? I once tried to write a compiler for it.
It used to be really popular, particularly in the late 1980s and 1990s. A really good language for learning object‑orientation (OO). Bertrand Meyer plugged it as a reliable language; it has keywords which cause Exceptions to be thrown if a class invariant is breached, or a loop variant doesn’t alter, etc. It is fully OO, even things like INTEGER being full‑blown objects. Unfortunately it has a context‑sensitive grammar, and about 2005 there were major changes to the language specification and many of its supporters deserted it. If you look at old Tiobe indices, you can watch it fall gradually from 15th position to the limbo of “not graded because the differences are too slight” in the >50 category.

change it to lowercase, then extract each character.
check the unicode(or ascii, i'm not sure which, but i think its unicode) of each character, to see if it falls in the range 48-57.
this can be done by
char c=string.charAt(1);//example
int x=c;
if(x<=48)&&(x>=57)
{
counter++;
}if the counter=string.length(), its a number, as each character is a number
I hope this helps!

Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3019

10

posted Sep 11, 2012 10:21:46

0

Um, yes. I think that's been suggested a few times now. Except this version has some fatal bugs; it won't count anything.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41599

31

posted Sep 12, 2012 03:52:10

0

Why are you changing the char to an int? Also using the number literals 48 and 57 is error‑prone. You should use char literals.

Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3019

10

posted Sep 12, 2012 07:01:25

0

Well, I was referring more to the fact that the inequalities are completely backwards.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41599

31

posted Sep 12, 2012 07:38:16

0

I wasn’t referring to the >= etc; that is a different error which will definitely cause problems. There is another feature about that line which I noticed and have kept quiet about, but which the compiler won’t keep quiet about.

Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3019

10

posted Sep 12, 2012 08:10:01

0

Yeah, this code has many problems.

In comparison, Character.isDigit() simply works.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 41599

31

posted Sep 12, 2012 08:13:07

0

Mike Simmons wrote: . . . Character.isDigit() . . .

I had forgotten about that. Even though I would appear to have been the first person to mention it on this discussion!