Simple way to Reverse an Array

A

Anno Siegel

Dr.Ruud said:
Anno Siegel:
Dr.Ruud:
Dr.Ruud:
A. Sinan Unur:
A. Sinan Unur <[email protected]>
(reverse each component and remove .invalid for email address)

echo '(e-mail address removed)' \
| perl -ple '@_=/(\w+|.)/g;pop@_,pop@_;$_=reverse@_=reverse@_'

| perl -ple 'split/(\W)/;pop@_;pop@_;$_=reverse@_=reverse@_'

| perl -ple 's/\.[^.]+$//;s/(\w+)/reverse$1/eg'

Much more pedestrian, but shorter is shorter.

Cool, but out of topic. <g>

It can be shortened to(o):

| perl -ple 's/.\w+$//;s/(\w+)/reverse$1/eg'

Nice. Dot matches dot, even unescaped.

Anno
 
D

Dr.Ruud

Anno Siegel:
Dr.Ruud:
Anno Siegel:
Dr.Ruud:
Dr.Ruud:
A. Sinan Unur:
A. Sinan Unur <[email protected]>
(reverse each component and remove .invalid for email address)

echo '(e-mail address removed)' \
| perl -ple '@_=/(\w+|.)/g;pop@_,pop@_;$_=reverse@_=reverse@_'

| perl -ple 'split/(\W)/;pop@_;pop@_;$_=reverse@_=reverse@_'

| perl -ple 's/\.[^.]+$//;s/(\w+)/reverse$1/eg'

| perl -ple 's/.\w+$//;s/(\w+)/reverse$1/eg'

Nice. Dot matches dot, even unescaped.

I had such a twist in my first version, and it was indeed nice to repeat
it.
 
M

Matt Garrish

A. Sinan Unur said:
(e-mail address removed) wrote in

[ I apologize for falling for this troll but I am posting this just in
case any of my students stumbles upon this posting. I will, under no
circumstances, post on this thread again. ]
A. Sinan Unur wrote: ...

Check out what students say about him at ratemyprofessors.com:

The URL is:

http://www.ratemyprofessors.com/ShowRatings.jsp?tid=479462

Honestly, over the last 15 years during which I have been teaching in
one capacity or another, I have received both better and worse
evaluations.

And really, aren't those sites mostly geared toward people with an axe to
grind? At least where I went to university, full polling of all students was
done each semester for each class, and the results were available in the
department office for the last couple of years if you wanted to look. A far
more accurate picture I would think, as the biggest complainers were
probably skipping class that day anyway, hence their inevitable failure...
: )

Matt
 
A

A. Sinan Unur

A. Sinan Unur said:
(e-mail address removed) wrote in

[ I apologize for falling for this troll but I am posting this just
in case any of my students stumbles upon this posting. I will, under
no circumstances, post on this thread again. ]
A. Sinan Unur wrote: ...

Check out what students say about him at ratemyprofessors.com:

The URL is:

http://www.ratemyprofessors.com/ShowRatings.jsp?tid=479462
....

And really, aren't those sites mostly geared toward people with an axe
to grind? At least where I went to university, full polling of all
students was done each semester for each class, and the results were
available in the department office for the last couple of years if you
wanted to look. A far more accurate picture I would think, as the
biggest complainers were probably skipping class that day anyway,
hence their inevitable failure...
: )

Breaking my promise immediately ;-)

My department has switched to anonymous online evaluations. These
evaluations are available for a period of about two weeks during the
finals period.

Once we turn in the grades, we receive printouts of everyone's input
(completely anonymized).

And we all get the occasional evaluation filled with profanities. In
fact, one of the evaluations I received last semester contained some
nasty language, but it was not representative.

I think there is a difference in what people say when they have to
actually put their thoughts on paper versus when they are just filling
in a form online.

Sinan
 
M

Matt Garrish

A. Sinan Unur said:
A. Sinan Unur said:
(e-mail address removed) wrote in

[ I apologize for falling for this troll but I am posting this just
in case any of my students stumbles upon this posting. I will, under
no circumstances, post on this thread again. ]

A. Sinan Unur wrote:
...

Check out what students say about him at ratemyprofessors.com:

The URL is:

http://www.ratemyprofessors.com/ShowRatings.jsp?tid=479462
...

And really, aren't those sites mostly geared toward people with an axe
to grind? At least where I went to university, full polling of all
students was done each semester for each class, and the results were
available in the department office for the last couple of years if you
wanted to look. A far more accurate picture I would think, as the
biggest complainers were probably skipping class that day anyway,
hence their inevitable failure...
: )

Breaking my promise immediately ;-)

My department has switched to anonymous online evaluations. These
evaluations are available for a period of about two weeks during the
finals period.

Once we turn in the grades, we receive printouts of everyone's input
(completely anonymized).

And we all get the occasional evaluation filled with profanities. In
fact, one of the evaluations I received last semester contained some
nasty language, but it was not representative.

I think there is a difference in what people say when they have to
actually put their thoughts on paper versus when they are just filling
in a form online.

Hmm, oddly like usenet... ; )

I was actually afraid that a prof would identify my comments by my
handwriting, though (until I learned that the comments were typed up before
being passed on). I actually had one prof look at my final exam in a third
year course and then ask me if I had been in his first year class because he
remembered my handwriting (yes, he explicitly said handwriting!). The
electronic experience does seem to encourage what would otherwise be
considered anti-social behaviour on the part of some people, but maybe we
should leave this topic to the sociologists.

Matt
 
J

John W. Krahn

Dr.Ruud said:
Anno Siegel:
Dr.Ruud:
Dr.Ruud:
A. Sinan Unur:
A. Sinan Unur <[email protected]>
(reverse each component and remove .invalid for email address)
echo '(e-mail address removed)' \
| perl -ple '@_=/(\w+|.)/g;pop@_,pop@_;$_=reverse@_=reverse@_'
| perl -ple 'split/(\W)/;pop@_;pop@_;$_=reverse@_=reverse@_'
| perl -ple 's/\.[^.]+$//;s/(\w+)/reverse$1/eg'

Much more pedestrian, but shorter is shorter.

Cool, but out of topic. <g>

It can be shortened to(o):

| perl -ple 's/.\w+$//;s/(\w+)/reverse$1/eg'

| perl -ple 's/.\w+$//;s/\w+/reverse$&/eg'


John
 
D

Dr.Ruud

John W. Krahn:
Dr.Ruud:
Anno Siegel:
Dr.Ruud:
Dr.Ruud:
A. Sinan Unur:
A. Sinan Unur <[email protected]>
(reverse each component and remove .invalid for email address)
echo '(e-mail address removed)' \
| perl -ple '@_=/(\w+|.)/g;pop@_,pop@_;$_=reverse@_=reverse@_'
| perl -ple 'split/(\W)/;pop@_;pop@_;$_=reverse@_=reverse@_'
| perl -ple 's/\.[^.]+$//;s/(\w+)/reverse$1/eg'
| perl -ple 's/.\w+$//;s/(\w+)/reverse$1/eg'

| perl -ple 's/.\w+$//;s/\w+/reverse$&/eg'

Thanks for exposing our prejudice.



Another array-reversing version:

| perl -aF'(\W)' -ple '$_=reverse reverse splice@F,0,-2'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top