comp.lang.ada
 help / color / mirror / Atom feed
* how to reverse output of a line using ada
@ 2000-11-21  0:00 Florian Paulus
  2000-11-21  0:00 ` Ted Dennison
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Florian Paulus @ 2000-11-21  0:00 UTC (permalink / raw)


Hi everybody!

I got the following task:

my program shall read a line and display it reversed.

e.g. "World" should become "dlroW"

is there any way to do this in Ada? i couldn't find any hint throughout the
net. just something like in reverse but i don't know how to use this.

thank you in advance

Florian Paulus







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

* Re: how to reverse output of a line using ada
  2000-11-21  0:00 how to reverse output of a line using ada Florian Paulus
  2000-11-21  0:00 ` Ted Dennison
  2000-11-21  0:00 ` Adrian Knoth
@ 2000-11-21  0:00 ` mjsilva
  2000-11-22  0:00 ` Paul Cass
  3 siblings, 0 replies; 5+ messages in thread
From: mjsilva @ 2000-11-21  0:00 UTC (permalink / raw)


In article <8ve870$4fkkm$1@ID-62217.news.dfncis.de>,
  "Florian Paulus" <mailme@ascat.de> wrote:
> Hi everybody!
>
> I got the following task:
>
> my program shall read a line and display it reversed.
>
> e.g. "World" should become "dlroW"
>
> is there any way to do this in Ada?

Certainly -- this is possible in any general-purpose language.

> i couldn't find any hint throughout the
> net. just something like in reverse but i don't know how to use this.

Think of the individual characters in the line as e.g. poker chips,
lined up in order.  How would you hand these poker chips to somebody,
one at a time in reverse order?  Once you can describe that process in
detail you can write the code.

BTW, if you don't know what poker chips are there in .de, just think of
individual squares of paper with single characters written on them...

Mike


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: how to reverse output of a line using ada
  2000-11-21  0:00 how to reverse output of a line using ada Florian Paulus
@ 2000-11-21  0:00 ` Ted Dennison
  2000-11-21  0:00 ` Adrian Knoth
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Ted Dennison @ 2000-11-21  0:00 UTC (permalink / raw)


In article <8ve870$4fkkm$1@ID-62217.news.dfncis.de>,
  "Florian Paulus" <mailme@ascat.de> wrote:

> I got the following task:
(task = homework?)

> my program shall read a line and display it reversed.
>
> e.g. "World" should become "dlroW"
>
> is there any way to do this in Ada? i couldn't find any hint

With older versions of the GreenHills Compiler, you could do this by
writing it to a stream. :-)

(That's now fixed, I understand).

--
T.E.D.

http://www.telepath.com/~dennison/Ted/TED.html


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* Re: how to reverse output of a line using ada
  2000-11-21  0:00 how to reverse output of a line using ada Florian Paulus
  2000-11-21  0:00 ` Ted Dennison
@ 2000-11-21  0:00 ` Adrian Knoth
  2000-11-21  0:00 ` mjsilva
  2000-11-22  0:00 ` Paul Cass
  3 siblings, 0 replies; 5+ messages in thread
From: Adrian Knoth @ 2000-11-21  0:00 UTC (permalink / raw)


Florian Paulus <mailme@ascat.de> wrote:

> Hi everybody!

Hi!

> my program shall read a line and display it reversed.

I'd do it this way:

with ustrings; use ustrings;
with ada.strings.unbounded; use ada.strings.unbounded;
with ada.text_IO; use ada.text_IO;

procedure bla is

        procedure output(what : in String) is
        begin
                for I in reverse what'range loop
                        Put(what(I));
                end loop;
        end output;

  buffer : ustring;

begin
        Get_Line(buffer);
        output(To_String(buffer));
end bla;


Please discuss.


-- 
mail: adi@thur.de	web: adi.thur.de	PGP: v2-key via keyserver

Q:Kann mir jemand helfen ? A: Du benutzt NT, Dir kann Keiner mehr helfen.




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

* Re: how to reverse output of a line using ada
  2000-11-21  0:00 how to reverse output of a line using ada Florian Paulus
                   ` (2 preceding siblings ...)
  2000-11-21  0:00 ` mjsilva
@ 2000-11-22  0:00 ` Paul Cass
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Cass @ 2000-11-22  0:00 UTC (permalink / raw)


There must be lots of ways to do this including reading into an array and
outputting in reverse.  However I suspect your tutor/lecturer wants you to
play with the "pred" and "succ" attributes.  You need to read about object
attributes, study the text_io package and simple array management.

Go try some algorithms - programming is meant to fun!

Cheers
Paul

"Florian Paulus" <mailme@ascat.de> wrote in message
news:8ve870$4fkkm$1@ID-62217.news.dfncis.de...
> Hi everybody!
>
> I got the following task:
>
> my program shall read a line and display it reversed.
>
> e.g. "World" should become "dlroW"
>
> is there any way to do this in Ada? i couldn't find any hint throughout
the
> net. just something like in reverse but i don't know how to use this.
>
> thank you in advance
>
> Florian Paulus
>
>
>






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

end of thread, other threads:[~2000-11-22  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-11-21  0:00 how to reverse output of a line using ada Florian Paulus
2000-11-21  0:00 ` Ted Dennison
2000-11-21  0:00 ` Adrian Knoth
2000-11-21  0:00 ` mjsilva
2000-11-22  0:00 ` Paul Cass

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