1

In a Luminus app here's a part of an action which produces an error:

                 some-var (if (rem total-records page-size)
                                     (quot total-records page-size)
                                     (+ 1 (quot total-records page-size)))

the error being clojure.lang.LazySeq cannot be cast to java.lang.Number. And this doesn't:

some-var 123

How to fix the error?

1 Answer 1

1

It looks that one of your variables total-pages and/or page-size is not a number but a seq whereas rem and quot functions require all its arguments to be numbers. Try to print it to console to check which one it is.

There is also another issue in your if expression: you want to use number value to test for truthiness. In Clojure any number value (including 0) is truthy (strictly speaking only niland false values are treated as falsehood) so you need to compare the result of rem to zero:

(if (zero? (rem a b)) 
  :truthy
  :falsey)
Sign up to request clarification or add additional context in comments.

4 Comments

I have this total-records (db/get-articles-total-count) . How can I to get it to evaluate?
How your get-articles-total-count looks like? It seems it returns a seq instead of bare number.
it returns a number, it's "select count(*)..."
Print the results of (db/get-articles-total-count) and I think you will see it is either a vector of hashmaps or a single hashmap.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.