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
| ;;today's timed kata from https://github.com/hoodja/practice-to-learn | |
| ;;down to 15 minutes today from 30 minutes previously | |
| (ns com.pillartechnology.practice | |
| (:use clojure.test midje.sweet)) | |
| (defn factors | |
| ([n] (factors n 2)) | |
| ([n c] | |
| (if (= n 1) | |
| [] |
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
| ;;Happy primes: inspired by watching Dr. Who episode 7 season 3 with my youngest son, John, on netflix | |
| ;;"don't they teach recreational mathematics any more?" -- Dr. Who, "42" | |
| ;;http://en.wikipedia.org/wiki/42_(Doctor_Who) | |
| ;;http://www.wolframalpha.com/input/?i=happy+numbers | |
| ;;Code was written in just the order you see things here, | |
| ;;in the bottom-up style of programming typical of Lisp and Smalltalk | |
| ;;In this recreational style I don't write tests, | |
| ;; but leave commented expressions you could evaluate near each function. |
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
| # -*- coding: utf-8 -*- | |
| # A simple class to calculate approximately any point on a circle defined by the radius | |
| class Circle | |
| def initialize(radius) # Might be actually the diameter; just whipping up some quick code | |
| @radius = radius | |
| end | |
| def [](theta) | |
| # π | |
| # You must multiply --- to convert theta from degrees to radians |
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
| 195 recipes | |
| 27 achievements | |
| 15:18:38 [INFO] Starting minecraft server version 1.3.1 | |
| 15:18:38 [INFO] Loading properties | |
| 15:18:38 [INFO] Default game type: SURVIVAL | |
| 15:18:38 [INFO] Generating keypair | |
| 15:18:38 [INFO] Starting Minecraft server on *:25565 | |
| 15:18:38 [INFO] This server is running CraftBukkit version git-Bukkit-1.3.1-R1.0-b2320jnks (MC: 1.3.1) (Implementing API version 1.3.1-R1.0) | |
| 15:18:38 [SEVERE] Could not load 'plugins/Purugin.jar' in folder 'plugins' |
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
| // from rosettacode | |
| let encode data = | |
| // encodeData : seq<'T> -> seq<int * 'T> i.e. Takes a sequence of 'T types and return a sequence of tuples containing the run length and an instance of 'T. | |
| let rec encodeData input = | |
| seq { if not (Seq.isEmpty input) then | |
| let head = Seq.head input | |
| let runLength = Seq.length (Seq.takeWhile ((=) head) input) | |
| yield runLength, head | |
| yield! encodeData (Seq.skip runLength input) } | |
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
| Set-ExplorerOptions -showHidenFilesFoldersDrives -showProtectedOSFiles -showFileExtensions | |
| Enable-RemoteDesktop |
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
| #nowarn "40" | |
| module exploreProgressBar = | |
| type Progress = BeginScope of string | SetProgress of float | EndScope | |
| let dialogAgent = MailboxProcessor.Start(fun inbox -> | |
| let rec messageLoop = async { | |
| // read a message | |
| let! msg = inbox.Receive() | |
| // process a message | |
| match msg with | |
| | BeginScope title -> printfn "Begin Scope %s - open dialog here" title |
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
| // bchop kata to spec http://codekata.com/kata/kata02-karate-chop/ (not idiomatic) | |
| type Comparision = Less|Equal|Greater | |
| let compare (a:int) b = | |
| match sign (a-b) with | |
| | 0 -> Equal | |
| | -1 -> Less | |
| | _ -> Greater | |
| compare 3 3 = Equal |
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
| // bchop kata more idiomatic http://codekata.com/kata/kata02-karate-chop/ | |
| // replacing that -1 with an option type flushed a bug at compile time | |
| type Comparision = Less|Equal|Greater | |
| let compare a b = if a = b then Equal else if a < b then Less else Greater | |
| compare 3 3 = Equal | |
| compare 2 3 = Less | |
| compare 3 2 = Greater | |
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
| // compare poker hands | |
| type Value = Number of int|Jack|Queen|King|Ace | |
| type Suit = Clubs|Spades|Hearts|Diamonds | |
| type Card = Value*Suit | |
| // tests - card comparisons | |
| [ | |
| (Ace,Hearts) > (King,Spades) | |
| (Number 7,Hearts) < (Jack,Clubs) |