Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

326
Vistas
Is it possible to force Clojure into using primitive types instead of their boxed versions?

I have a following sample of code:

(type (apply / [5.0 0]))

It throws an unexpected error - "Division By Zero" (expected behavior: return Inf)

Probably, it happens due to auto-boxing - can it be prevented?

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Assuming you just want to use a two argument division on doubles, the following might work.

user=> (apply (fn d2div [n d] (double (/ (double n) (double d)))) [5.0 0.0])
##Inf

If you go down this path, check out clj-cmmons/primitive-math.

over 4 years ago · Santiago Trujillo Denunciar

0

How about

user=> (defmacro myapply [func args] `(~func ~@args))
#'user/myapply
user=> (myapply / [5.0 0])
##Inf
user=> (type (myapply / [5.0 0]))
java.lang.Double

I didn't know that apply behaves in such a different manner in Clojure.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda