An open API service indexing awesome lists of open source software.

https://github.com/benzap/litter

Number Literals Utility Library in clojure(script)
https://github.com/benzap/litter

clojure clojurescript literals utility

Last synced: 3 months ago
JSON representation

Number Literals Utility Library in clojure(script)

Awesome Lists containing this project

README

        

#+TITLE: Litter - Number Literal Utility Library in Clojure(script)
#+AUTHOR: Benjamin Zaporzan
#+DATE: 2018-10-04
#+EMAIL: [email protected]
#+LANGUAGE: en
#+OPTIONS: H:2 num:t toc:t \n:nil ::t |:t ^:t f:t tex:t

* What is it for?
To express big numbers in an easier to read way. Especially numbers
with repeating zeros. It can be difficult to read 100000000, when
it could be expressed as (lit/num :100M)

* examples

General Number Literals
#+BEGIN_SRC clojure
(require '[litter.core :as lit])

(lit/num "100") ;; 100
(lit/num "100,000") ;; 100000
(lit/num "100,000.2345") ;; 100000.2345
(lit/num "100,000,000") ;; 100000000
(lit/num :100M) ;; 100000000
(lit/num :100M2k20m) ;; 100002000.020
(lit/num :100M20M2k) ;; ERROR
(lit/num "100,000,000,00") ;; ERROR
#+END_SRC