I have 2 questions related to bigints.

1) I've read things suggesting Clojure auto-converts between int, long, and 
bigint to prevent overflow.  That isn't the behavior I've experienced.  Did 
something change from an older release of Clojure to more recent ones?

2) I found myself wanting to write a function that would use bigint math vs 
not depending on whether I passed a bigint in as arg.  Internally I wanted 
to "seed" a reduce call with either 1 or 1N as appropriate.  So I wanted to 
write something like this (except I'd like it to work):

(defn foo [n]
  (cast (type n) 1))

; (foo 3) => 1
; (foo 42N) => 1N

The following works, but I'd like to understand if I can avoid the 
conditional:

(defn foo [n]
  (if (= clojure.lang.BigInt (type n)) 1N 1))

-- 
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
Note that posts from new members are moderated - please be patient with your 
first post.
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to