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.routes | |
(:use compojure.core | |
hiccup.core) | |
(:require [clj-http.client :as client] | |
[compojure.route :as route] | |
[clj-json.core :as json])) | |
;Make everything £40 for simplicity | |
(defn calculate-price [vehicle] | |
(assoc vehicle :price-per-day 40)) |
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
#light | |
open SdlDotNet.Core; | |
open SdlDotNet.Graphics; | |
open SdlDotNet.Graphics.Sprites; | |
open SdlDotNet.Input; | |
open System.Drawing; | |
open System; | |
type StuperGario = class | |
val mutable location : Point |
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
module Tools | |
open System | |
let sqr x = float(x * x) (* Square two ints into a float *) | |
(* Remove element where predicate *) | |
let rec remove l predicate = | |
match l with | |
| [] -> [] | |
| hd::tl -> if predicate(hd) then |
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
module Pathfinding | |
open Level | |
open Tools | |
(* a wrapper for mapPoint that can contain pathing data as per typical A* pathfinding *) | |
(* g = cost of path so far, h = estimated cost to goal, parent = tile we came here from *) | |
type PathingNode = | |
{point:MapPoint; h:float; g:float; parent:PathingNode option} | |
member this.f = this.g + this.h |
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
module Level | |
open Tools | |
type MapPoint = | |
{x:int;y:int;value:int} (* a point in 2d map space *) | |
(*Calculate distance to other map point*) | |
member this.Distance mp = sqrt (sqr(this.x+mp.x) + sqr(this.y+mp.y)) | |
(*Simple construct to hold the 2D map data*) | |
type 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
open Tools | |
open Level | |
open Pathfinding | |
let level1 = {width=5;height=9;map=(loadMap @"C:\Test\lvl1.txt" |> Seq.toList)} | |
let start = level1.GetElement 4 8 | |
let goal = level1.GetElement 4 0 | |
let path = pathFind(level1,goal,start,[{point=start;h=start.Distance goal;g=0.0;parent=None}],[]) | |
let rec readPath (path:PathingNode, list:PathingNode list) = |
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
module Pathfinding | |
open Level | |
open Tools | |
(* a wrapper for mapPoint that can contain pathing data as per typical A* pathfinding *) | |
(* g = cost of path so far, h = estimated cost to goal, parent = tile we came here from *) | |
type PathingNode = | |
{point:MapPoint; h:float; g:float; parent:PathingNode option} | |
(* returns a pathnode based on a given map point *) |
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
module Tools | |
open System | |
let sqr x = float(x * x) | |
let rec remove l predicate = | |
match l with | |
| [] -> [] | |
| hd::tl -> if predicate(hd) then | |
(remove tl predicate) |
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 xml_test.core | |
(:require [clojure.zip :as zip] | |
[clojure.xml :as xml] | |
[clj-json.core :as json]) | |
(:use clojure.contrib.zip-filter.xml)) | |
(defn -main [& args] | |
(let [paintings (zip/xml-zip (xml/parse "paintings.xml"))] | |
(->> (xml-> paintings :painting) | |
(map (fn [painting] { :name (first (xml-> painting :img (attr :alt))) |
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
puts 'Hello, World' |
OlderNewer