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

Discussion in 'Ruby' started by x1, Oct 3, 2005.

  1. x1

    x1 Guest

    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
    x1, Oct 3, 2005
    #1
    1. Advertising

  2. x1

    Hal Fulton Guest

    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
    Hal Fulton, Oct 3, 2005
    #2
    1. Advertising

  3. --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

    --8323328-918706930-1128307788=:19080--
    --8323328-918706930-1128307788=:19080--
    David A. Black, Oct 3, 2005
    #3
  4. x1

    x1 Guest

    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 <> 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
    >
    >
    >
    x1, Oct 3, 2005
    #4
  5. x1

    robbie Guest

    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
    http://groups.google.com/group/comp...ead/thread/7650c939ca5f9881/ead3540b101ce5b4?
    robbie, Oct 3, 2005
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rastislav Struharik

    Reverse engineering an EDIF file?

    Rastislav Struharik, Nov 10, 2003, in forum: VHDL
    Replies:
    8
    Views:
    7,919
    Joonas Timo Taavetti Kekoni
    Jan 2, 2004
  2. Shannon Yoder

    How do I list records in reverse order?

    Shannon Yoder, Aug 14, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    380
  3. John Lundrigan

    Reverse Web Project Transfer

    John Lundrigan, Oct 17, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    416
    Tim Stephenson
    Oct 20, 2003
  4. Guest
    Replies:
    1
    Views:
    406
    William F. Robertson, Jr.
    Oct 28, 2003
  5. dogbite
    Replies:
    4
    Views:
    682
    osmium
    Oct 10, 2003
Loading...

Share This Page