Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor bug in the parse-number fn in parse.cljs #124

Open
dvdreddy opened this issue Feb 9, 2018 · 0 comments
Open

Minor bug in the parse-number fn in parse.cljs #124

dvdreddy opened this issue Feb 9, 2018 · 0 comments

Comments

@dvdreddy
Copy link

dvdreddy commented Feb 9, 2018

(defn parse-number
  ([s limit] (parse-number s 1 limit))
  ([s lower upper]
   (let [[n s] (read-while #(re-find #"\d" %) s)]
     (if (>= (count n) lower)
       [(js/parseInt (apply str (take upper n))) (concat (drop upper n) s)]
       [(js/parseInt (apply str n)) s]))))

The logic is checking if the (>= (count n) lower) instead it should check for (>= (count n) upper) then it should be dropping the elements

Also js/parseInt is dependent on the platform if the radix is not defined and was giving wierd behavior on local rhino platform by considering default radix as 8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant