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
module Main where | |
import Control.Applicative | |
import Control.Monad | |
import Data.Maybe (fromJust, isJust) | |
import Network.Curl (curlGetString, URLString) | |
import qualified Text.XML.Light as XML | |
url = "http://search.twitter.com/search.atom?q=haskell&rpp=10" |
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 InverseFizzBuzz extends App { | |
implicit def makeSeqSafer[A](xs: Seq[A]) = new { | |
def safeMinBy[B](f: A => B)(implicit cmp: Ordering[B]) = | |
if (xs.nonEmpty) Some(xs.minBy(f)) else None | |
} | |
def solve(words: Seq[String]): Option[(Int, Int)] = { | |
List(3,5,6,9,10,12,15).flatMap { x => | |
val (subseq, pos) = Stream.from(x).collect { |
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
;; Inverse Fizzbuzz - just another scala quant - http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html | |
(ns inverse-fizzbuzz.core | |
(:use [clojure.test :only (deftest are)])) | |
(defn unzip [coll] | |
(if-not (empty? coll) | |
(apply map list coll))) |
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
;; Inverse Fizzbuzz - just another scala quant - http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html | |
;; UPDATED 2012/05/20: This code is wrong, because this only finds the index of the first sub sequence of fizzbuzz sequence. | |
(ns inverse-fizzbuzz.core) | |
(defn fizzbuzz [] | |
(map #(cond (zero? (mod % 15)) "fizzbuzz" | |
(zero? (mod % 3)) "fizz" | |
(zero? (mod % 5)) "buzz" |
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
;; (defproject async-test2 "1.0.0-SNAPSHOT" | |
;; :description "FIXME: write description" | |
;; :dependencies [[org.clojure/clojure "1.3.0"] | |
;; [aleph "0.2.1-alpha1"]]) | |
(ns async-test2.core | |
(:use lamina.core | |
aleph.http)) |
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
;; (defproject async-test1 "1.0.0-SNAPSHOT" | |
;; :description "FIXME: write description" | |
;; :dependencies [[org.clojure/clojure "1.3.0"] | |
;; [http.async.client "0.4.0"]] | |
;; :dev-dependencies [[swank-clojure "1.3.4"]]) | |
(ns async-test1.core | |
(:require [http.async.client :as client] | |
[http.async.client.request :as request])) |
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
use v5.14; | |
use warnings; | |
sub hoge { | |
say do { | |
given (wantarray) { | |
when (undef) { "void" } | |
when (0) { "scalar" } | |
when (1) { "list" } | |
} |
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
;; use prove on *.t file | |
(quickrun-add-command "perl/test" | |
'((:command . "prove") | |
(:exec . "%c -v %s") | |
(:description . "Run Perl Test script"))) | |
(add-to-list 'quickrun-file-alist '("\\.t$" . "perl/test")) |
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
(defadvice quickrun/apply-outputter (after quickrun/fix-scroll-buffer activate) | |
(recenter)) |
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
;; From https://github.com/overtone/live-coding-emacs/blob/master/lib/durendal/durendal.el | |
(defun clojure-slime-repl-fix-syntax () | |
(modify-syntax-entry ?\{ "(}") | |
(modify-syntax-entry ?\} "){") | |
(modify-syntax-entry ?\[ "(]") | |
(modify-syntax-entry ?\] ")[") | |
(modify-syntax-entry ?~ "' ") | |
(modify-syntax-entry ?, " ") | |
(modify-syntax-entry ?^ "'") |