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 std::fmt; | |
use std::error::Error; | |
struct Foo; | |
impl Error for Foo { | |
fn description(&self) -> &str { "foo" } | |
} | |
impl fmt::Display for Foo { |
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
{-# LANGUAGE Rank2Types #-} | |
import Control.Applicative | |
import Control.Arrow | |
import Control.Monad | |
import Control.Monad.Trans.Maybe | |
import Control.Monad.Trans.Reader | |
import Control.Monad.Trans.State | |
import Control.Monad.Trans.Writer | |
import Data.Monoid |
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
問題13 | |
リストのリストを取って、要素のリストを連結する関数concat :: [[a]] -> [a]は 第6章の演習問題で定義した。これをfoldrを使って実装した関数concatRを 定義せよ。さらに、foldlを使って実装した関数concatLを定義せよ。 | |
以下の実行例で自分の定義が正しいことを確認せよ。 | |
> concatR [[1,2],[3],[],[4,5]] | |
[1,2,3,4,5] | |
> concatL [[1,2],[3],[],[4,5]] | |
[1,2,3,4,5] | |
> concatR [] |
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 sh | |
## | |
# This is script with usefull tips taken from: | |
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
# | |
# install it: | |
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
# |
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 Distribution.Simple | |
main = defaultMain |
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 map-incr-unsafe [] | |
(let [m (java.util.HashMap.)] | |
(.put m "a" 0) | |
(doseq [i (range 1000000)] | |
(let [a (.get m "a")] | |
(.put m "a" (inc a)) | |
)))) | |
(defn map-incr-safe [] | |
(let [o (Object.) |
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
;; pepijndevos's solution to Least Common Multiple | |
;; https://4clojure.com/problem/100 | |
#(reduce(fn[n r](* r(numerator(/ n r))))%&) |
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
;; answer to what I understood of http://d.hatena.ne.jp/fatrow/20100407/1270662784 | |
;; your original code | |
(en/defsnippet lib-model "src/html/a.html" [:.library] | |
[{:keys [name description url category]}] | |
[:.name] (en/content name) | |
[:.descriptionj] (en/content description) | |
[:.site :a] (en/do-> (en/set-attr :href url) | |
(en/content url)) |