Liking cljdoc? Tell your friends :D

unicode-math

A Clojure library designed to let you painfully write easily readable math.

Examples

Binet's Fibonacci Number Formula:

(defn binet-fib [n]
  (/ (- (ⁿ φ n)
        (ⁿ (- φ) (- n)))
     (√ 5)))

de Morgan's Laws:

(assert (∀ [p [true false] q [true false]]
             (= (¬ (∧ p q))
                (∨ (¬ p) (¬ q)))))

Inclusion-Exclusion Principle:

(assert (= (count (∪ A B))
           (+ (count A)
              (count B)
              (- (count (∩ A B))))))

Usage

Add the following to your project.clj:

[unicode-math "0.2.0"]

The full list of implemented symbols is in src/unicode_math/core.clj.

Unicode in your editor

Emacs

Emacs has simple Unicode support out of the box. I recommend reading Xah Lee's Emacs & Unicode Tips to learn all of the functionality, but the critical commands are:

  • C-x 8 <return> or M-x insert-char, which will prompt you for a character name or hexadecimal code point.
  • C-\ or M-x toggle-input-method, which will prompt you for an input method name the first time and then toggle between your current input method and the one that you specify. I use the "greek-babel" input method, as I'm frequently using Greek letters as variables in formulas.
  • M-x describe-char, which will display the character code and full Unicode name in the Help buffer.

Vim

Vim users can use the digraph functionality to quickly insert most of the Unicode characters used in unicode-math. For the characters that don't have digraphs, CTRL-V can be used.

Disclaimer

It's almost certainly a bad idea to use this, but it's fun.

License

Copyright © 2013 Matthew Adereth

Distributed under the Eclipse Public License, the same as Clojure.

Can you improve this documentation?Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close