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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var james = new Person( | |
name: "James", | |
age: 31, | |
deceased: false); | |
} | |
} |
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 get_filename(obj) | |
filename = obj.to_s.downcase + '.txt' | |
end | |
def read_line(line) | |
line.chomp.split(', ') | |
end | |
module ActsAsCsv | |
def self.included(base) |
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
(1..16).to_a.each {|i| i % 4==0 ? puts(i) : print(i) } |
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' |
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
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
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
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 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
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 |