知り合いの主催する勉強会イベント「孤独のHaskell 第二話」http://www.zusaar.com/event/502008 があったので、参加してきました。 みなさん自由な感じで特に発表などもなく、好きに過ごす感じです。
そんな中、Haskell初心者な私は
- 「すごいHaskellたのしく学ぼう」を教科書に
- 「今日はIOをできるようになろう!」を目標に
(use srfi-42) | |
(define (dfs E0 E R vs) | |
(match vs | |
[ () 0] | |
[ (v . vs) | |
(max-ec (:range e 0 (+ E 1)) | |
(+ (* v e) | |
(dfs E0 | |
(min E0 (+ E R (- e))) |
#! /usr/bin/env python | |
import sys | |
def zigzag(sig, steps): | |
while True: | |
yield (sig, steps) | |
sig *= -1 | |
steps += 1 | |
def locus(x, motion): | |
i = 0 |
{- | Polymorphic version of @Codec.Archive.LibZip@. | |
Codec.Archive.Libzip is with useful and simple API, and a high-leveled library to deal with zip archives. | |
...Although, in the library, specification way of the path to a file inside a zip archive is `String`. | |
This limitation is inconvenient especially when dealing with zip archived file | |
of which path contains foreign system's multi-byte characters. | |
This module provides APIs of polymorphic version, | |
which can specify and receive archived file's path as String or Data.ByteString (as you like). |
import Codec.Text.IConv as IConv | |
import Codec.Binary.UTF8.String as UTF8 | |
import Data.ByteString as B | |
import Data.ByteString.Lazy as BL | |
import System.IO as IO | |
convertDetect :: [ IConv.EncodingName ] -> IConv.EncodingName -> BL.ByteString -> | |
Either BL.ByteString (IConv.EncodingName, BL.ByteString) | |
convertDetect [] _ src = Left src | |
convertDetect (srcEnc:srcEncs) dstEnc src = case IConv.convertStrictly srcEnc dstEnc src of |
知り合いの主催する勉強会イベント「孤独のHaskell 第二話」http://www.zusaar.com/event/502008 があったので、参加してきました。 みなさん自由な感じで特に発表などもなく、好きに過ごす感じです。
そんな中、Haskell初心者な私は
(defn fib [n] | |
(let [a-fib (atom false)] | |
(reset! a-fib (memoize (fn [n] (if (< 1 n) (+ (@a-fib (- n 1)) (@a-fib (- n 2))) 1)))) | |
(@a-fib n) | |
)) | |
;;; inspired by @tnoda | |
(def ^:dynamic *m-fib*) | |
(defn fibv [n] | |
(binding [*m-fib* (memoize (fn [x] (if (< 1 x) (+ (*m-fib* (- x 1)) (*m-fib* (- x 2))) 1)))] |
(def solve | |
(memoize | |
(fn [w h] | |
(if (or (zero? w) | |
(zero? h)) | |
1 | |
(+ (solve (dec w) h) | |
(solve w (dec h))) | |
)))) |
;;; :s/0\ze\d/ /g | |
(def original-grid | |
[[ 8 2 22 97 38 15 0 40 0 75 4 5 7 78 52 12 50 77 91 8] | |
[49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 4 56 62 0] | |
[81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 3 49 13 36 65] | |
[52 70 95 23 4 60 11 42 69 24 68 56 1 32 56 71 37 2 36 91] | |
[22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80] | |
[24 47 32 60 99 3 45 2 44 75 33 53 78 36 84 20 35 17 12 50] | |
[32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70] | |
[67 26 20 68 2 62 12 20 95 63 94 39 63 8 40 91 66 49 94 21] |
;;; Project Euler Problem 23 solution | |
;;; http://projecteuler.net/problem=23 | |
(use 'clojure.test) | |
(def limit 28123) | |
(defn gen-sigma1-list | |
"original implementation by @ypsilon-takai: https://gist.github.com/4284814" | |
[^long size] |
https://gist.github.com/4357479 で「ダイナミックスコープな変数であるかどうか」をプログラムから(というかreplから)知る方法について調べた経緯です。
*print-readably*
を対象にして調べる途上で出会ったいろいろなものについて、とりとめなくgdgdに書いています。
replで *print-readably*
だけみると、値については教えてくれますが、変数については教えてくれません。
さっきのしらべものの途中で見つけた http://d.hatena.ne.jp/athos/20111204/elephant_things_in_clojure に #'fact
の表記があったため、試してみたところ
pe-16.core=> #'*print-readably*