Velocity Reviews > Ruby > (4+3).reverse # => 1?

# (4+3).reverse # => 1?

x1
Guest
Posts: n/a

 10-03-2005
Does anything like this exist?

a method of inversing the given operation..

(4=B2).revese # yields 2, the square of 4
(8/4).reverse # yields 32, the product of 8*4

Hal Fulton
Guest
Posts: n/a

 10-03-2005
x1 wrote:
> Does anything like this exist?
>=20
> a method of inversing the given operation..
>=20
> (4=B2).revese # yields 2, the square of 4
> (8/4).reverse # yields 32, the product of 8*4

No... and what you're asking for doesn't really
make sense, as expressions are evaluated from
the inside out:

(8/4).methcall

would be the same as

2.methcall

Make sense?

Hal

David A. Black
Guest
Posts: n/a

 10-03-2005
--8323328-918706930-1128307788=:19080
Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-918706930-1128307788=:19080"

This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.

--8323328-918706930-1128307788=:19080
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

Hi --

On Mon, 3 Oct 2005, x1 wrote:

> Does anything like this exist?
>
> a method of inversing the given operation..
>
> (4=B2).revese # yields 2, the square of 4
> (8/4).reverse # yields 32, the product of 8*4

I don't think it could, and I know that it shouldn't The thing
is, whatever follows the dot is being sent to the object that's
returned by the expression (8/4), and not to the expression itself.
So you're asking to reverse 2.

David

--=20
David A. Black
http://www.velocityreviews.com/forums/(E-Mail Removed)
--8323328-918706930-1128307788=:19080--
--8323328-918706930-1128307788=:19080--

x1
Guest
Posts: n/a

 10-03-2005
Hal.. good point.

lol.. Ok.. ("8/2").inverse_cal # =3D> 16

//my way of running

I was actually studing some finance crap and ran by a definition for
term x.. in taking notes, I wrote down something like..
x - the date when x blah

then there was a term, non-x which is
non-x the date when x not blah

Me being lazy an a ruby enthusiast wrote down
non-x =3D x.reverse

lol.. then my brain started thing about reversing more than just
strings.. logic.. bah.. I'm a nut. --disregard.

On 10/2/05, David A. Black <(E-Mail Removed)> wrote:
> Hi --
>
> On Mon, 3 Oct 2005, x1 wrote:
>
> > Does anything like this exist?
> >
> > a method of inversing the given operation..
> >
> > (4=B2).revese # yields 2, the square of 4
> > (8/4).reverse # yields 32, the product of 8*4

>
> I don't think it could, and I know that it shouldn't The thing
> is, whatever follows the dot is being sent to the object that's
> returned by the expression (8/4), and not to the expression itself.
> So you're asking to reverse 2.
>
>
> David
>
> --
> David A. Black
> (E-Mail Removed)
>
>

robbie
Guest
Posts: n/a

 10-03-2005
The problem, as has been pointed out, is that the expression in the
brackets gets evaluated before the reverse method. In order to control
evaluation of parts of an expression you need something like Lisp
macros, which would be extremely difficult to add to ruby and,
according to matz, too dangerous.

For a more thorough discussion on this point, see