Skip to content

Instantly share code, notes, and snippets.

@claj
Created September 11, 2013 16:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claj/6526542 to your computer and use it in GitHub Desktop.
Save claj/6526542 to your computer and use it in GitHub Desktop.
Some rules I've found useful in Kibit.
;;trivial identites
[(+ ?x 0) ?x]
[(- ?x 0) ?x]
[(* ?x 1) ?x]
[(/ ?x 1) ?x]
[(* ?x 0) 0]
;;Math/pow
[(* ?x ?x) (Math/pow ?x 2) ]
[(* ?x ?x ?x) (Math/pow ?x 3) ]
[(* ?x ?x ?x ?x) (Math/pow ?x 4) ]
[(* ?x ?x ?x ?x ?x) (Math/pow ?x 5) ]
;;Math/hypot
[(Math/sqrt (+ (Math/pow ?x 2) (Math/pow ?y 2))) (Math/hypot ?x ?y)]
;;Math/expm1
[(dec (Math/exp ?x)) (Math/expm1 ?x)]
;;ugly rounding tricks
[(long (+ ?x 0.5)) (Math/round ?x)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment