I've seen different theories on how mod should treat negative divisors, but
I've never seen that "solution".

On Tue, Feb 10, 2009 at 4:30 PM, Chouser <chou...@gmail.com> wrote:

>
> Is 'mod' working correctly?
>
> user=> (map #(mod % 3) (range -9 9))
> (3 1 2 3 1 2 3 1 2 0 1 2 0 1 2 0 1 2)
>
> It disagrees with, for example, Ruby:
>
> irb(main):002:0> (-9..9).map{|x| x % 3}
> => [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0]
>
> And python:
>
> >>> map( lambda x: x % 3, range(-9,9) )
> [0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2]
>
> --Chouser
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to