- JDKがinstall済みであること
- java コマンドに環境変数Pathが通っていること
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
trait Memorized[T,R] { | |
import scala.collection.mutable._ | |
val cache = new HashMap[T,R] | |
def cacheOrApply( t:T )( f: => R ):R = cache get(t) getOrElse{ | |
val rv = f | |
cache += t -> rv | |
println("do %s:%s" format(t, rv)) | |
rv | |
} |
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
import qualified Data.Map as M | |
import XMonad | |
import qualified XMonad.StackSet as W | |
import XMonad.Actions.WindowGo | |
import XMonad.Actions.CycleWS | |
import XMonad.Hooks.ManageDocks | |
import XMonad.Hooks.EwmhDesktops | |
import XMonad.Layout |
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
import io.Source | |
import scala.actors.Actor._ | |
// Regex to pick up external links; very simplified, so it'll miss some | |
val linkRegex = "(?i)<a.+?href=\"(http.+?)\".*?>(.+?)</a>".r | |
object PageLoader { | |
def load(url: String) = { | |
try { | |
Source.fromURL(url).mkString |
Here is a comparison of two pieces of code that do basically the same thing.
So what we have here is a chain of functions depending on each other, each consecutive takes the result of the previous one for further processing. If either of them fails, the rest shall not be executed.
- validate parameters received from the outside world in a Hash
- convert one of the parameters into an object
- do a search in the database
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
" == Naming convention. == {{{1 | |
" Command name | |
" - CamelCase | |
" Global function name | |
" - CamelCase | |
" Local function name | |
" - s:split_by_underbar | |
" Group name for autocmd | |
" - split-by-dash | |
" In vimrc, start with "vimrc" |
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
// data Free f a = Pure a | Free (f (Free f a)) | |
// | |
// instance Functor f => Monad (Free f) where | |
// return = Pure | |
// Pure a >>= k = k a | |
// Free fm >>= k = Free (fmap (>>=k) fm) | |
sealed trait FreeM[S[+_], +A] { | |
private case class FlatMap[S[+_], A, +B](a: FreeM[S, A], f: A => FreeM[S, B]) extends FreeM[S, B] |
この記事は、lispリーダーマクロアドベントカレンダー の4日目の記事です。 タイトルにある通り、Clojure でのリー ダーマクロについて取り扱います(対象とする Clojure のバージョンは 1.4)。
OlderNewer