[#3986] Re: Principle of least effort -- another Ruby virtue. — Andrew Hunt <andy@...>

> Principle of Least Effort.

14 messages 2000/07/14

[#4043] What are you using Ruby for? — Dave Thomas <Dave@...>

16 messages 2000/07/16

[#4139] Facilitating Ruby self-propagation with the rig-it autopolymorph application. — Conrad Schneiker <schneik@...>

Hi,

11 messages 2000/07/20

[ruby-talk:03809] Re: modulo and remainder

From: "Conrad Schneiker" <schneiker@...>
Date: 2000-07-04 23:12:54 UTC
List: ruby-talk #3809
Hi,

"Yukihiro Matsumoto" writes:

> In message "[ruby-talk:03779] Re: modulo and remainder"
>     on 00/07/04, Tadayoshi Funaba <tadf@kt.rim.or.jp> writes:
>
> |I wrote a method jd_to_wday in date2.rb like this:
> |
> |    def jd_to_wday(jd) (jd + 1) % 7 end
> |
> |It calculates the day of week of the given the Julian day number.
> |I used % and it must be modulo.  So it works even if jd is -ve.
>
> Hmm.
>
> |BTW, I wish divmod to behave like floor in Common Lisp or Python's.

A possible big advantage of emulating Python's behavior (which was hopefully
well thought out--but I'm not an expert on that) is that it would make
converting/porting Python's numeric libraries (and stuff built on them) to
Ruby much less tricky and error prone.

> |And we may use floor, ceil and round in all numerical domain, I think.
> |(Integer#floor just returns self) Ruby has some restrictions in math,
> |I think.  I don't need that.
>
> It reflects the author's weakpoint.  Even if you don't need that
> (weakness in mathematical field?), I can't do the right thing without
> YOUR help.  Enlighten me, please.

Conrad



In This Thread