comp.lang.ada
 help / color / mirror / Atom feed
* Case statement and Integers.
@ 2002-04-20 16:42 Wannabe h4x0r
  2002-04-20 17:04 ` Rhoady
                   ` (3 more replies)
  0 siblings, 4 replies; 19+ messages in thread
From: Wannabe h4x0r @ 2002-04-20 16:42 UTC (permalink / raw)


I have a statement like this...

	case numbers(j) is
		when numbers(j) < pivot => swap(left_swap, right_swap); 
		-- If the number is less than the pivot, swap it with the number
		-- to the right of the Pivot;
		when numbers(j) > pivot => swap(right_swap, left_swap);
		-- If the number is greater than the pivot, then do the opposite of the
		-- above.
		when numbers(j) = pivot => null;
		when others => null;
	end case;

Now, it's pretty obvious whats wrong here. The swap procedure is
expecting an Integer, and instead it's getting a boolean value due to the
'>', '<', and '=>' operators.

Whats the proper way to indicate to the compiler that I want to send
the numbers indexed by "left_swap" and "right_swap" to the swap procedure
rather than the results of the boolean test in the case statement?

Thanks for your patience.

Chris



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 16:42 Case statement and Integers Wannabe h4x0r
@ 2002-04-20 17:04 ` Rhoady
  2002-04-20 17:11 ` Alan Reynolds
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 19+ messages in thread
From: Rhoady @ 2002-04-20 17:04 UTC (permalink / raw)


How about a nested IF like so:

  if Numbers(j) < Pivot then
    Swap (Left_Swap, Right_swap);
  elsif Numbers(j) < Pivot then
    Swap (Right_Swap, Left_Swap);
  else
    Null;
  end if;

This appears to be the 'guts' of a sort so I assume that this is inside a
for loop steping through the values of J.  And that J is being used to index
the array Numbers.  What I do not have a clue about is Pivot, Right_Swap and
Left_Swap.  Where are they set and to what values.

Jeff

"Wannabe h4x0r" <chris@dont.spam.me> wrote in message
news:YTgw8.79490$G72.56764@sccrnsc01...
> I have a statement like this...
>
> case numbers(j) is
> when numbers(j) < pivot => swap(left_swap, right_swap);
> -- If the number is less than the pivot, swap it with the number
> -- to the right of the Pivot;
> when numbers(j) > pivot => swap(right_swap, left_swap);
> -- If the number is greater than the pivot, then do the opposite of the
> -- above.
> when numbers(j) = pivot => null;
> when others => null;
> end case;
>
> Now, it's pretty obvious whats wrong here. The swap procedure is
> expecting an Integer, and instead it's getting a boolean value due to the
> '>', '<', and '=>' operators.
>
> Whats the proper way to indicate to the compiler that I want to send
> the numbers indexed by "left_swap" and "right_swap" to the swap procedure
> rather than the results of the boolean test in the case statement?
>
> Thanks for your patience.
>
> Chris





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 16:42 Case statement and Integers Wannabe h4x0r
  2002-04-20 17:04 ` Rhoady
@ 2002-04-20 17:11 ` Alan Reynolds
  2002-04-20 17:32   ` Wannabe h4x0r
  2002-04-20 19:14 ` Vadim Godunko
  2002-04-22 16:58 ` Anatoly Chernyshev
  3 siblings, 1 reply; 19+ messages in thread
From: Alan Reynolds @ 2002-04-20 17:11 UTC (permalink / raw)


Hi Chris,

It would seem that you need to review the RM (or course notes) 
concerning the use of the "case" statement and what constitutes a valid 
alternative ("when <discrete_choice_list> =>").  What's appropriate here 
is to use an "if ... then ... elsif ... then ... else ... end if" statement.

If "left_swap" and "right_swap" are indices similar to "j" then you 
simply provide "numbers(left_swap)" and "numbers(right_swap)" as 
arguments to "swap".

This brings back fond memories of my 2nd quarter comp. sci. class 
assignment to implement the "quicksort" algorithm in Pascal.  Keep 
working on it.

Have fun,
Al

Wannabe h4x0r wrote:
> I have a statement like this...
> 
> 	case numbers(j) is
> 		when numbers(j) < pivot => swap(left_swap, right_swap); 
> 		-- If the number is less than the pivot, swap it with the number
> 		-- to the right of the Pivot;
> 		when numbers(j) > pivot => swap(right_swap, left_swap);
> 		-- If the number is greater than the pivot, then do the opposite of the
> 		-- above.
> 		when numbers(j) = pivot => null;
> 		when others => null;
> 	end case;
> 
> Now, it's pretty obvious whats wrong here. The swap procedure is
> expecting an Integer, and instead it's getting a boolean value due to the
> '>', '<', and '=>' operators.
> 
> Whats the proper way to indicate to the compiler that I want to send
> the numbers indexed by "left_swap" and "right_swap" to the swap procedure
> rather than the results of the boolean test in the case statement?
> 
> Thanks for your patience.
> 
> Chris




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 17:11 ` Alan Reynolds
@ 2002-04-20 17:32   ` Wannabe h4x0r
  2002-04-20 18:31     ` tmoran
  2002-04-20 21:26     ` Ted Dennison
  0 siblings, 2 replies; 19+ messages in thread
From: Wannabe h4x0r @ 2002-04-20 17:32 UTC (permalink / raw)


On Sat, 20 Apr 2002 13:11:07 -0400, Alan Reynolds wrote:

> Hi Chris,
> 
> It would seem that you need to review the RM (or course notes)
> concerning the use of the "case" statement and what constitutes a valid
> alternative ("when <discrete_choice_list> =>").  What's appropriate here
> is to use an "if ... then ... elsif ... then ... else ... end if"
> statement.
> 
> If "left_swap" and "right_swap" are indices similar to "j" then you
> simply provide "numbers(left_swap)" and "numbers(right_swap)" as
> arguments to "swap".
> 
> This brings back fond memories of my 2nd quarter comp. sci. class
> assignment to implement the "quicksort" algorithm in Pascal.  Keep
> working on it.
> 
> Have fun,
> Al

I'm looking over the RM now. The course notes didnt provide much info in
this regard, as it assumed I would be using an if..else statement
structure in the sort.
Not me. No way. I gotta be different. I have this irresistable urge to
zig while everyone else in the course zags.(Been pretty successful so
far). I have to think up a solution that nobody else (at my level) has
thought of before. Using an if..else statement wouldn't be original. Heh.

The fun part is when the professor plops my code up on the projector and
says "Now this is how Chris did it." Cause I'm crazy like that.

Thanks.

Chris



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 17:32   ` Wannabe h4x0r
@ 2002-04-20 18:31     ` tmoran
  2002-04-21  3:59       ` Wannabe h4x0r
                         ` (2 more replies)
  2002-04-20 21:26     ` Ted Dennison
  1 sibling, 3 replies; 19+ messages in thread
From: tmoran @ 2002-04-20 18:31 UTC (permalink / raw)


>       case numbers(j) is
>               when numbers(j) < pivot => swap(left_swap, right_swap);
>               when numbers(j) > pivot => swap(right_swap, left_swap);
>               when numbers(j) = pivot => null;
>               when others => null;

  The items after the "when" must be constant values of "numbers(j)".
This code has dynamic boolean expressions.  "case" is not just another
syntax for "if then".  When the compiler sees a "case" statement it
should, at least conceptually if not in implementation, be able to create
a jump table indexed by the value of "numbers(j)".  It clearly can't do
that here.
If you had a comparison function
  type Compare_Results is (LT, EQ, GT);
  function Compare(Left, Right : Numbers_Type) return Compare_Results;
then you could say
  case Compare(numbers(j), pivot) is
    when LT =>
    when GT =>
    when EQ =>
  end case;
because the compiler could create a three-entry jump table.

> Using an if..else statement wouldn't be original.
  Bicycling to Hawaii is original - but it won't work either.  In
Software Engineering, the point is to make something that works, not
necessarily something original.  In fact, since you will abandon most of
your code to your maintenance successors (one hopes you move on to new
things!), and originality will just confuse them, originality itself is a
downright *negative* aspect of code, to be used only when the negative is
outweighed by the positive benefits of the novel technique.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 16:42 Case statement and Integers Wannabe h4x0r
  2002-04-20 17:04 ` Rhoady
  2002-04-20 17:11 ` Alan Reynolds
@ 2002-04-20 19:14 ` Vadim Godunko
  2002-04-22  3:05   ` Robert Dewar
  2002-04-22 16:58 ` Anatoly Chernyshev
  3 siblings, 1 reply; 19+ messages in thread
From: Vadim Godunko @ 2002-04-20 19:14 UTC (permalink / raw)



case Numbers(J) is
   when Numbers (J) in Numbers_Array_Element_Type'First .. Pivot - 1 =>
      swap ...
   when Numbers (J) in Pivot + 1 .. Numbers_Array_Element_Type'Last =>
      swap ...
   when others =>
      null;
end case;

----- Original Message ----- 
From: "Wannabe h4x0r" <chris@dont.spam.me>
Newsgroups: comp.lang.ada
Sent: Saturday, April 20, 2002 8:42 PM
Subject: Case statement and Integers.


> I have a statement like this...
> 
> case numbers(j) is
> when numbers(j) < pivot => swap(left_swap, right_swap); 
> -- If the number is less than the pivot, swap it with the number
> -- to the right of the Pivot;
> when numbers(j) > pivot => swap(right_swap, left_swap);
> -- If the number is greater than the pivot, then do the opposite of the
> -- above.
> when numbers(j) = pivot => null;
> when others => null;
> end case;
> 
> Now, it's pretty obvious whats wrong here. The swap procedure is
> expecting an Integer, and instead it's getting a boolean value due to the
> '>', '<', and '=>' operators.
> 
> Whats the proper way to indicate to the compiler that I want to send
> the numbers indexed by "left_swap" and "right_swap" to the swap procedure
> rather than the results of the boolean test in the case statement?
> 
> Thanks for your patience.
> 
> Chris




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 17:32   ` Wannabe h4x0r
  2002-04-20 18:31     ` tmoran
@ 2002-04-20 21:26     ` Ted Dennison
  1 sibling, 0 replies; 19+ messages in thread
From: Ted Dennison @ 2002-04-20 21:26 UTC (permalink / raw)


Wannabe h4x0r wrote:

> Not me. No way. I gotta be different. I have this irresistable urge to
> zig while everyone else in the course zags.(Been pretty successful so


Which is great, as long as you don't zig straight into a concrete pylon. :-)

> thought of before. Using an if..else statement wouldn't be original. Heh.


Comming up with creative solutions to complex problems is what computer 
science is all about. Your creativity is what is going to bail you out 
of a millon problems in the future. So there's nothing wrong with being 
original, just do it for the right reasons. Often times there's a good 
reason everyone is doing it a certian way. So if your "original" 
solution is more work and less easy to follow (and for you to get 
working), you should probably give the boring approach another look. :-)






^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 18:31     ` tmoran
@ 2002-04-21  3:59       ` Wannabe h4x0r
  2002-04-22  3:01       ` Robert Dewar
  2002-04-22  5:14       ` Anders Wirzenius
  2 siblings, 0 replies; 19+ messages in thread
From: Wannabe h4x0r @ 2002-04-21  3:59 UTC (permalink / raw)


On Sat, 20 Apr 2002 14:31:04 -0400, tmoran wrote:

>   The items after the "when" must be constant values of "numbers(j)".
> This code has dynamic boolean expressions.  "case" is not just another
> syntax for "if then".  When the compiler sees a "case" statement it
> should, at least conceptually if not in implementation, be able to
> create a jump table indexed by the value of "numbers(j)".  It clearly
> can't do that here.
> If you had a comparison function
>   type Compare_Results is (LT, EQ, GT); function Compare(Left, Right :
>   Numbers_Type) return Compare_Results;
> then you could say
>   case Compare(numbers(j), pivot) is
>     when LT =>
>     when GT =>
>     when EQ =>
>   end case;
> because the compiler could create a three-entry jump table.
> 

This technique works but ...

>> Using an if..else statement wouldn't be original.
>   Bicycling to Hawaii is original - but it won't work either.  In
> Software Engineering, the point is to make something that works, not
> necessarily something original.  In fact, since you will abandon most of
> your code to your maintenance successors (one hopes you move on to new
> things!), and originality will just confuse them, originality itself is
> a downright *negative* aspect of code, to be used only when the negative
> is outweighed by the positive benefits of the novel technique.

... your point is well taken. I suppose I do have a tendency to go
overboard.
I'll keep your technique in mind, but will for the time being defer to
the if...then...else method of doing the sort.

Thanks

Chris



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 18:31     ` tmoran
  2002-04-21  3:59       ` Wannabe h4x0r
@ 2002-04-22  3:01       ` Robert Dewar
  2002-04-22  5:14       ` Anders Wirzenius
  2 siblings, 0 replies; 19+ messages in thread
From: Robert Dewar @ 2002-04-22  3:01 UTC (permalink / raw)


tmoran@acm.org wrote in message news:<Itiw8.3026>

> Bicycling to Hawaii is original - but it won't work either.  In
> Software Engineering, the point is to make something that works, not
> necessarily something original.  In fact, since you will abandon most of
> your code to your maintenance successors (one hopes you move on to new
> things!), and originality will just confuse them, originality itself is a
> downright *negative* aspect of code, to be used only when the negative is
> outweighed by the positive benefits of the novel technique.

Very nice post. Indeed, "originality considered harmful" would be a fun 
title for an extended article on the above theme. "cleverness considered
harmful" would be an appropriate sequel :-)



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 19:14 ` Vadim Godunko
@ 2002-04-22  3:05   ` Robert Dewar
  2002-04-22  8:41     ` Vadim Godunko
  2002-04-23  6:38     ` Wannabe h4x0r
  0 siblings, 2 replies; 19+ messages in thread
From: Robert Dewar @ 2002-04-22  3:05 UTC (permalink / raw)


"Vadim Godunko" <vgodunko@vipmail.ru> wrote in message news:<mailman.1019330222.4196.comp.lang.ada@ada.eu.org>...

> case Numbers(J) is
>    when Numbers (J) in Numbers_Array_Element_Type'First .. Pivot - 1 =>
>       swap ...
>    when Numbers (J) in Pivot + 1 .. Numbers_Array_Element_Type'Last =>
>       swap ...
>    when others =>
>       null;
> end case;

Please don't post junk code. If you are trying to be deliberately unhelpful,
do it by email. If you really think that the above is correct, you are as
seriously confused as the questioner :-)

As always, I suggest that people actually compile any sample code they
think of suggesting on CLA.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 18:31     ` tmoran
  2002-04-21  3:59       ` Wannabe h4x0r
  2002-04-22  3:01       ` Robert Dewar
@ 2002-04-22  5:14       ` Anders Wirzenius
  2 siblings, 0 replies; 19+ messages in thread
From: Anders Wirzenius @ 2002-04-22  5:14 UTC (permalink / raw)



tmoran@acm.org wrote in message ...

>  Bicycling to Hawaii is original - but it won't work either.  In
>Software Engineering, the point is to make something that works, not
>necessarily something original.  In fact, since you will abandon most of
>your code to your maintenance successors (one hopes you move on to new
>things!), and originality will just confuse them, originality itself is a
>downright *negative* aspect of code, to be used only when the negative is
>outweighed by the positive benefits of the novel technique.

I think the main goal here is not to produce something that works. The goal
is to learn a computer language. One very good way to learn is to do
something in several different ways and concentrate on what the alternatives
demand from the syntax or logic.
Mr Wannabe h4x0r, please keep up being, as you say in an earlier posting,
"crazy like that". Solve the problem, not in one way, not in two ways, no,
do it in as many ways you may imagine. Compare the ways and watch your
reaction to the different solutions. Then you may discover something very
valuable about Ada.
And of course, nothing prevents you from choosing the "winner code" that is
most efficient, most readable, most maintainable... then you may discover
something about Software Engineering.
br
Anders Wirzenius





^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-22  3:05   ` Robert Dewar
@ 2002-04-22  8:41     ` Vadim Godunko
  2002-04-22 13:16       ` Robert Dewar
  2002-04-23  6:38     ` Wannabe h4x0r
  1 sibling, 1 reply; 19+ messages in thread
From: Vadim Godunko @ 2002-04-22  8:41 UTC (permalink / raw)


Sorry, this is my mistake. The correct expamle:

case Numbers (J) is
   when Numbers_Array_Element_Type'First .. Pivot - 1 =>
      ...
   when Pivot + 1 .. Numbers_Array_Element_Type'Last =>
      ...
   when others =>
      null;
end case;

and, Pivot must be constant.

----- Original Message -----
From: "Robert Dewar" <dewar@gnat.com>
Newsgroups: comp.lang.ada
Sent: Monday, April 22, 2002 7:05 AM
Subject: Re: Case statement and Integers.


> "Vadim Godunko" <vgodunko@vipmail.ru> wrote in message
news:<mailman.1019330222.4196.comp.lang.ada@ada.eu.org>...
>
> > case Numbers(J) is
> >    when Numbers (J) in Numbers_Array_Element_Type'First .. Pivot - 1 =>
> >       swap ...
> >    when Numbers (J) in Pivot + 1 .. Numbers_Array_Element_Type'Last =>
> >       swap ...
> >    when others =>
> >       null;
> > end case;
>
> Please don't post junk code. If you are trying to be deliberately
unhelpful,
> do it by email. If you really think that the above is correct, you are as
> seriously confused as the questioner :-)
>
> As always, I suggest that people actually compile any sample code they
> think of suggesting on CLA.




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
@ 2002-04-22  9:11 Grein, Christoph
  0 siblings, 0 replies; 19+ messages in thread
From: Grein, Christoph @ 2002-04-22  9:11 UTC (permalink / raw)


> Sorry, this is my mistake. The correct expamle:
> 
> case Numbers (J) is
>    when Numbers_Array_Element_Type'First .. Pivot - 1 =>
>       ...
>    when Pivot + 1 .. Numbers_Array_Element_Type'Last =>
>       ...
>    when others =>
>       null;
> end case;
> 
> and, Pivot must be constant.

No, it must be static! Non-static choices are allowed only if there is just one 
choice with this value (except for an additional others choice).



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-22  8:41     ` Vadim Godunko
@ 2002-04-22 13:16       ` Robert Dewar
  0 siblings, 0 replies; 19+ messages in thread
From: Robert Dewar @ 2002-04-22 13:16 UTC (permalink / raw)


"Vadim Godunko" <vgodunko@vipmail.ru> wrote in message news:<mailman.1019465466.24117.comp.lang.ada@ada.eu.org>...
> Sorry, this is my mistake. The correct expamle:
> 
> case Numbers (J) is
>    when Numbers_Array_Element_Type'First .. Pivot - 1 =>
>       ...
>    when Pivot + 1 .. Numbers_Array_Element_Type'Last =>
>       ...
>    when others =>
>       null;
> end case;

I can only repeat what I said before:
> > Please don't post junk code. If you are trying to be deliberately
> > unhelpful,
> > do it by email. If you really think that the above is correct, you are as
> > seriously confused as the questioner :-)
> >
> > As always, I suggest that people actually compile any sample code they
> > think of suggesting on CLA.



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-20 16:42 Case statement and Integers Wannabe h4x0r
                   ` (2 preceding siblings ...)
  2002-04-20 19:14 ` Vadim Godunko
@ 2002-04-22 16:58 ` Anatoly Chernyshev
  2002-04-22 17:55   ` tmoran
  2002-04-24 11:41   ` Robert Dewar
  3 siblings, 2 replies; 19+ messages in thread
From: Anatoly Chernyshev @ 2002-04-22 16:58 UTC (permalink / raw)


Well, he was probably trying to say approximately the following:
-------This is the compilable and working example---------------------
with text_io;
use text_io;
procedure af is
numbers: array (1..100) of integer;
pivot:constant integer:=30;
begin
for j in 1..100 loop
numbers(j):=j;
case Numbers(J) is
    when 1..Pivot - 1 =>
put_line (integer'image (j) & " is smaller than " & integer'image(pivot));
    when Pivot + 1 .. 100 =>
put_line (integer'image (j) & " is larger than " & integer'image(pivot));
    when others =>
put_line (integer'image (j) & " is equal to " & integer'image(pivot));
 end case;
 end loop;
end af;
---------------------------------------------------------------------------------------------------



"Grein, Christoph" wrote:

> > Sorry, this is my mistake. The correct expamle:
> >
> > case Numbers (J) is
> >    when Numbers_Array_Element_Type'First .. Pivot - 1 =>
> >       ...
> >    when Pivot + 1 .. Numbers_Array_Element_Type'Last =>
> >       ...
> >    when others =>
> >       null;
> > end case;
> >
> > and, Pivot must be constant.
>
> No, it must be static! Non-static choices are allowed only if there is just one
> choice with this value (except for an additional others choice).






^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-22 16:58 ` Anatoly Chernyshev
@ 2002-04-22 17:55   ` tmoran
  2002-04-22 19:51     ` Anatoly Chernyshev
  2002-04-24 11:41   ` Robert Dewar
  1 sibling, 1 reply; 19+ messages in thread
From: tmoran @ 2002-04-22 17:55 UTC (permalink / raw)


> pivot:constant integer:=30;
> begin
> for j in 1..100 loop
> numbers(j):=j;
> case Numbers(J) is
>     when 1..Pivot - 1 =>      ...
>     when Pivot + 1 .. 100 =>  ...
>     when others =>
> put_line (integer'image (j) & " is equal to " & integer'image(pivot));
>  end case;
>  end loop;
It must be Monday morning.  Insert the line
  if j = 5 then numbers(j) = 500;end if;
and you will be surprised to find that " 5 is equal to  30"



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-22 17:55   ` tmoran
@ 2002-04-22 19:51     ` Anatoly Chernyshev
  0 siblings, 0 replies; 19+ messages in thread
From: Anatoly Chernyshev @ 2002-04-22 19:51 UTC (permalink / raw)


As usual with the open source, you can modify them at your own risk. This
sample did not assume any usefulness in numbers comparison, it is just to
illustrate use of the case selection.

tmoran@acm.org wrote:

> > pivot:constant integer:=30;
> > begin
> > for j in 1..100 loop
> > numbers(j):=j;
> > case Numbers(J) is
> >     when 1..Pivot - 1 =>      ...
> >     when Pivot + 1 .. 100 =>  ...
> >     when others =>
> > put_line (integer'image (j) & " is equal to " & integer'image(pivot));
> >  end case;
> >  end loop;
> It must be Monday morning.  Insert the line
>   if j = 5 then numbers(j) = 500;end if;
> and you will be surprised to find that " 5 is equal to  30"




^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-22  3:05   ` Robert Dewar
  2002-04-22  8:41     ` Vadim Godunko
@ 2002-04-23  6:38     ` Wannabe h4x0r
  1 sibling, 0 replies; 19+ messages in thread
From: Wannabe h4x0r @ 2002-04-23  6:38 UTC (permalink / raw)


On Sun, 21 Apr 2002 23:05:57 -0400, Robert Dewar wrote:

> Please don't post junk code. If you are trying to be deliberately
> unhelpful, do it by email. If you really think that the above is
> correct, you are as seriously confused as the questioner :-)

Thanks for the vote of confidence Mr. Dewar. ;->

> As always, I suggest that people actually compile any sample code they
> think of suggesting on CLA.

A good habit to get into. 

Also, for any serious "production" code, from now on I will stick to the
tried and true methods. But dont expect that to quell my curiosity or
experimental streak at all. 

Thanks.

Chris
NiCad



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: Case statement and Integers.
  2002-04-22 16:58 ` Anatoly Chernyshev
  2002-04-22 17:55   ` tmoran
@ 2002-04-24 11:41   ` Robert Dewar
  1 sibling, 0 replies; 19+ messages in thread
From: Robert Dewar @ 2002-04-24 11:41 UTC (permalink / raw)


Anatoly Chernyshev <rhezusfactor@yahoo.com> wrote in message news:<3CC44130.6472A3C8@yahoo.com>...
> Well, he was probably trying to say approximately the following:
> -------This is the compilable and working example---------------------
> with text_io;
> use text_io;
> procedure af is
> numbers: array (1..100) of integer;
> pivot:constant integer:=30;
> begin
> for j in 1..100 loop
> numbers(j):=j;
> case Numbers(J) is
>     when 1..Pivot - 1 =>
> put_line (integer'image (j) & " is smaller than " & integer'image(pivot));
>     when Pivot + 1 .. 100 =>
> put_line (integer'image (j) & " is larger than " & integer'image(pivot));
>     when others =>
> put_line (integer'image (j) & " is equal to " & integer'image(pivot));
>  end case;
>  end loop;
> end af;

Yes, of course this is compilable, but we perfectly well know that it is 100%
irrelevant to the original post, where obvviously the pivot was a dynamic value.



^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2002-04-24 11:41 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-20 16:42 Case statement and Integers Wannabe h4x0r
2002-04-20 17:04 ` Rhoady
2002-04-20 17:11 ` Alan Reynolds
2002-04-20 17:32   ` Wannabe h4x0r
2002-04-20 18:31     ` tmoran
2002-04-21  3:59       ` Wannabe h4x0r
2002-04-22  3:01       ` Robert Dewar
2002-04-22  5:14       ` Anders Wirzenius
2002-04-20 21:26     ` Ted Dennison
2002-04-20 19:14 ` Vadim Godunko
2002-04-22  3:05   ` Robert Dewar
2002-04-22  8:41     ` Vadim Godunko
2002-04-22 13:16       ` Robert Dewar
2002-04-23  6:38     ` Wannabe h4x0r
2002-04-22 16:58 ` Anatoly Chernyshev
2002-04-22 17:55   ` tmoran
2002-04-22 19:51     ` Anatoly Chernyshev
2002-04-24 11:41   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
2002-04-22  9:11 Grein, Christoph

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox