Reverse Polish Notation calculator kata
Useful info:
Reverse Polish Notation algorithm explanation
Online Reverse Polish Notation Calculator to check your results.
Examples:
| ;; | |
| ;; Destructuring | |
| ;; | |
| ;; Destructuring is a concise syntax for declaratively pulling apart collections and | |
| ;; binding values contained therein as named locals within a let form. | |
| ;; (Clojure Programming, Chas Emerick, Brian Carper, Christophe Grand) | |
| ;; Since it's a facility provided by let, it can be used | |
| ;; in any expression that implicitly uses let (like fn, defn, loop, etc). |
| (def test-address | |
| {:street-address "123 Test Lane" | |
| :city "Testerville" | |
| :state "TX"}) | |
| ;"Destructuring is an arbiter: it breaks up arguments" | |
| (= "__" ((fn [[a b]] (str b a)) | |
| [:foo :bar])) | |
| ;"Whether in function definitions" |
Reverse Polish Notation calculator kata
Useful info:
Reverse Polish Notation algorithm explanation
Online Reverse Polish Notation Calculator to check your results.
Examples:
| ;;-------------- | |
| ;; | |
| ;; A bit about Clojure functions | |
| ;; | |
| ;;-------------- | |
| ;; Functions are first class values in Clojure. | |
| ;;-------------- | |
| ;; 1. fn form |
| (defn- happy? [n visited] | |
| (if (contains? visited n) | |
| false | |
| (if (= n 1) | |
| true | |
| (let [ndigits (decompose-in-digits n) | |
| sum-of-squares (apply + (map square ndigits))] | |
| (recur sum-of-squares (conj visited n)))))) |
"_Ab3ccc" -> ok "c" -> wrong "_b3c" -> wrong "_Ab3cc" -> wrong "_Abcccc" -> wrong
| (ns password-validator.core) | |
| (defn- has-more-than-6-chars? [password] | |
| (> (count password) 6)) | |
| (defn- any? [pred coll] | |
| (not= nil (some pred coll))) | |
| (def ^:private contains-at-least-one-upper-case-char? | |
| (partial any? #(Character/isUpperCase %))) |
| app.factory('Track', [ | |
| '$http', | |
| '$resource', | |
| 'dateStringsInsideObjectsIntoDates', | |
| 'appendTransform', | |
| 'ApiBaseUrl', | |
| 'trackMethods', | |
| function ( | |
| $http, |