This file contains hidden or 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 trip.core | |
(:require [[clj-time.core :as t] | |
[clojure.set :as set]])) | |
(defn default-trip | |
"returns a default trip with current date as start date & end date as 5 days from now" | |
[] | |
{ :name "New Trip" | |
:description "Enter your trip description here" | |
:start-date (t/today) |
This file contains hidden or 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
(defproject webapp "0.1.0-SNAPSHOT" | |
:description "Web Application in Clojure" | |
:url "http://localhost/groupie" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.6.0"] | |
[ring "1.3.1"] | |
[http-kit "2.1.16"] | |
[compojure "1.1.9"] |
This file contains hidden or 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 webapp.server | |
(:require [ring.middleware.resource :refer [wrap-resource]] | |
[ring.middleware.file-info :refer [wrap-file-info]] | |
[ring.middleware.reload :refer [wrap-reload]] | |
[compojure.core :refer :all] | |
[compojure.route :as route] | |
[org.httpkit.server :refer [run-server]])) | |
(defroutes route-map |
This file contains hidden or 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 webapp.client | |
(:require | |
[figwheel.client :as fw :include-macros true])) | |
(fw/watch-and-reload) | |
(js/alert "Hello Zumanji") | |
This file contains hidden or 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
<html> | |
<body> | |
Welcome to clojure world! | |
<script type="text/javascript" src="js/goog/base.js"></script> | |
<script src="js/main.js" type="text/javascript"></script> | |
<script text="text/javascript"> | |
goog.require("webapp.client"); | |
</script> |
This file contains hidden or 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
//tail recursive fibonacci numbers | |
def fib(n: Int) = { | |
@scala.annotation.tailrec | |
def fibImpl(a:Int, nxt: Int, res: Int) : Int = | |
a match { | |
case 0 => res | |
case _ => fibImpl(a-1, nxt+res, nxt) | |
} | |
fibImpl(n, 1, 0); | |
} |
This file contains hidden or 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
def isSorted[A] (items : Seq[A], ordered : (A,A) => Boolean) : Boolean = | |
(items, items.tail).zipped.forall(ordered) | |
/*items match { | |
case null => true | |
case x :: Nil => true | |
case x :: y :: xs => ordered (x, y) && isSorted (xs, ordered) | |
}*/ | |
isSorted(Seq(1,2,3), (a: Int, b: Int) => a < b); | |
This file contains hidden or 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
def curry[A,B,C] (f: (A,B) => C): A => (B => C) = a => b => f(a,b) | |
curry((a:Int, b:Int) => a * b)(1)(2) | |
def uncurry [A,B,C] (f: A => B => C) : (A,B) => C = (a,b) => f(a)(b) | |
var f = uncurry (curry((a:Int, b: Int) => a * b)) // f (3,5) = 15 |
This file contains hidden or 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
def compose[A,B,C] (f: B => C, g : A => B) : A => C = a => f(g(a)) |
This file contains hidden or 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
import org.atmosphere.config.service.WebSocketHandlerService | |
import org.atmosphere.nettosphere.{Config, Nettosphere} | |
import org.atmosphere.websocket.{WebSocket, WebSocketHandlerAdapter} | |
object Main { | |
def main(args: Array[String]) { | |
val builder = new Config.Builder().host("127.0.0.1").port(8080) |