This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(deftest test-do-register | |
(let [uname "username" | |
lngname "thisisalongusername" | |
bname "$#%^$djc" | |
pwd "password" | |
shpwd "pass" | |
email "test@test.com" | |
bemail "testing.com"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(em/defsnippit snippit1 "templates/template1.html" [:tbody :> 'first-child] | |
[fruit quantity] | |
[:tr :> 'first-child] (ef/content fruit) | |
[:tr :> 'last-child] (ef/content (str quantity))) | |
(em/deftemplate template1 "/templates/template1.html" [fruit-data] | |
[:#heading1] (ef/content "fruit") | |
[:thead :tr :> 'last-child] (ef/content "quantity") | |
[:tbody] (ef/content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns midje.cljs.basic) | |
(defn doubler [x] (* 2 x)) | |
(defn world [] "world") | |
(defn hello [] | |
(str "hello " (world))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns goog-test.core | |
(:require [goog.testing.jsunit :as unit] | |
[goog.testing :as gt] | |
[goog.testing.TestCase :as tc]) | |
(:use [midje.cljs.core :only [run-test]]) | |
(:use-macros [midje.cljs.semi-sweet :only [expect fact run-tests]] | |
[midje.cljs.sweet :only [fact provided]])) | |
(defn world [] "world") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;you have a map with a key :action | |
;this contains a known list of actions: | |
;:login, :register, :play, :logout | |
(defmulti appy-action :action) | |
;input looks like this | |
;{:action :login :username "test" :password "test"} | |
(defmethod apply-action :login [msg] | |
(let [username (:username msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use '[clojure.core.match :only [match]]) | |
(defn evaluate [env [sym x y]] | |
(match [sym] | |
['Number] x | |
['Add] (+ (evaluate env x) (evaluate env y)) | |
['Multiply] (* (evaluate env x) (evaluate env y)) | |
['Variable] (env x))) | |
(def environment {"a" 3, "b" 4, "c" 5}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
┌───┬────────────┬──────────────────────────────────┐ | |
│Add│┌────────┬─┐│┌────────┬──────────┬────────────┐│ | |
│ ││Variable│a│││Multiply│┌──────┬─┐│┌────────┬─┐││ | |
│ │└────────┴─┘││ ││Number│2│││Variable│b│││ | |
│ │ ││ │└──────┴─┘│└────────┴─┘││ | |
│ │ │└────────┴──────────┴────────────┘│ | |
└───┴────────────┴──────────────────────────────────┘ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Number = lambda { |env, num| num } | |
Variable = lambda { |env, var| env[var] } | |
Add = lambda { |env, a, b| evaluate(env, a) + evaluate(env, b) } | |
Multiply = lambda { |env, a, b| evaluate(env, a) * evaluate(env, b) } | |
def evaluate(env, exp) | |
op, *args = exp | |
op.(env, *args) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Lambda extends App { | |
val number = (num: Int) => (env: Map[Symbol, Int]) => num | |
val variable = (id: Symbol) => (env: Map[Symbol, Int]) => env(id) | |
val add = (a: (Map[Symbol, Int]) => Int, b: (Map[Symbol, Int]) => Int ) => (env: Map[Symbol, Int]) => a(env) + b(env) | |
val multiply = (a: (Map[Symbol, Int]) => Int, b: (Map[Symbol, Int]) => Int ) => (env: Map[Symbol, Int]) => a(env) * b(env) | |
val environment = Map('a -> 1, 'b -> 2, 'c -> 3) | |
val expr_tree = add(variable('a), multiply(number(2), variable('b))) | |
println(expr_tree(environment)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defrecord Tree [left elm right]) | |
(defprotocol Monoid | |
(append [a b] ) | |
(identity [a] )) | |
(defprotocol Foldable | |
(foldl [l f i]) | |
(mfirst [l])) | |
OlderNewer