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 TypeclasseDemo { | |
// The parts of the type class pattern are: | |
// | |
// 1. the "type class" itself -- a trait with a single type parameter; | |
// | |
// 2. type class "instances" for each type we care about, | |
// each marked with the `implicit` keyword; | |
// | |
// 3. an "interface" to the type class -- one or more methods |
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
(defn parse-flags | |
"Parse a list of flags. Each flag name must be a keyword, and the | |
value must not be a keyword. If the value is omitted, true is | |
assumed. Returns a map. | |
e.g. (parse-flags [:i :j 1 :k \"two\"]) | |
=> {:i true, :j 1, :k \"two\"}" | |
[flags] | |
(loop [flags (seq flags) accum {}] | |
(if flags |
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
;; Perl: $RE{num}{-base => 2}{real}{-group => 3}{-sep => ','} | |
(re-seq (re :real {:base 2 :group 3 :sep \,} ) "1.345") |
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
#! /usr/bin/env ruby | |
# Author:: Sébastien Briois (sebriois@gmail.com) | |
require "rubygems" | |
require "rest_client" | |
require "json" | |
IDCC_SITE = "http://user:pass@localhost:3000" |