Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile
@ajiyoshi-vg
ajiyoshi-vg / gist:d72b2cae129d73a405e4
Last active August 29, 2015 14:10
if式 / if文 の条件節で、左辺に定数を書くべき言語はあるか? @ajiyoshi.gist

if式 / if文 の条件節で、左辺に定数を書くべき言語はあるか? @ajiyoshi.gist

twitterからながれてきたこの話題。昔のCコンパイラは、if文の条件節で代入を書いても文句を言わなかったので、このようなコードに何の警告も出なかった。

#include<stdio.h>

int main() {
  int x = 0;
  /* おそらく意図と違うx == 1 と書くべきであった
@mpickering
mpickering / client.hs
Last active October 18, 2015 16:33 — forked from jaspervdj/client.hs
--------------------------------------------------------------------------------
{-# LANGUAGE OverloadedStrings #-}
module Main
( main
) where
--------------------------------------------------------------------------------
import Control.Concurrent (forkIO)
import Control.Applicative ((<$>))
@e-jigsaw
e-jigsaw / contMap.coffee
Last active August 29, 2015 14:13 — forked from lotz84/contEach.js
contMap = (arr, f, g, ans) ->
if ans is undefined then ans = []
if arr.length is 0 and typeof g is 'function' then return g ans else return
f.apply @, [
arr.shift()
(item)-> contMap arr, f, g, ans.concat([item])
ans
]
# Example
@sile
sile / pfds-ch1.md
Last active June 24, 2021 01:09
Purely Functional Data Structures: 第1章

序文

  • 筆者はもともとC/Pascal/Adaを書いていた
  • Standard MLを書くようになり、手続き型のデータ構造を(SMLに)変換してみた
    • 幾つかのデータ構造は、簡単に変換でき、より簡潔にもなった
    • ただし、必ずしも全てのデータ構造が簡単に変換できる訳ではなかった
      • 破壊的な更新が使いたい! (けどStandard MLにはないのでどうすれば...)
      • 文献調査したけど、ほとんど情報が見つからなかった
  • 自分で研究を始めた
@chrisdotcode
chrisdotcode / Promise.hs
Created February 16, 2015 00:07
Abstract Promises in Haskell
module Promise where
import Control.Applicative (Applicative(..))
import Data.Monoid (Monoid(..))
newtype Error = Error { unString :: String } deriving (Eq, Ord, Read, Show)
data Promise a = Failed Error | Deferred | Fulfilled a
deriving (Eq, Ord, Read, Show)
@sile
sile / pfds-ch6.md
Last active January 9, 2019 15:15
Purely Functional Data Structures: 第6章

6 遅延評価を使った償却と永続性

前章の題材:

  • 償却というアイディアの提示
  • 良い償却計算量を有するいくつかのデータ構造の紹介

償却の問題点:

  • 永続性とは相性が悪い
@paulirish
paulirish / bling.js
Last active May 26, 2025 20:31
bling dot js
/* bling.js */
window.$ = document.querySelector.bind(document);
window.$$ = document.querySelectorAll.bind(document);
Node.prototype.on = window.on = function(name, fn) { this.addEventListener(name, fn); };
NodeList.prototype.__proto__ = Array.prototype;
NodeList.prototype.on = function(name, fn) { this.forEach((elem) => elem.on(name, fn)); };
@sile
sile / pfds-7.md
Last active June 30, 2019 20:34
Purely Functional Data Structures: 第7章

第7章 償却を除去する

memo: スケジューリングの役割

  • イメージ的には銀行員の手法での__支払い__を実装に反映した感じ
  • 後ろに重いサスペンションが控えている場合の挙動の違い:
    • 6章(償却):「軽い操作で__仮想的に__その内のN個のデビットを払ったことにしておこう」
    • 7章(最悪):「軽い操作で__実際に__その内のN個の(小さな)サスペンションを事前に評価しておこう」
  • 支払い(or 評価)が終わっていないオブジェクト(サスペンション)に対するアクセスは許可されない
@sile
sile / 0_raft.md
Last active May 27, 2024 07:53
Raft(分散合意アルゴリズム)について
@avieth
avieth / gist:334201aa341d9a00c7fc
Last active July 22, 2022 13:42
Interpreting Free Monads of Functor Sums
Interpreting Free Monads of Functor Sums
========================================
This text deals with a way to compose certain kinds of monads, thereby mixing
their capabilities. It is a literate Haskell file, so let's begin with a
bunch of noise.
> {-# LANGUAGE MultiParamTypeClasses #-}
> {-# LANGUAGE FlexibleInstances #-}
> {-# LANGUAGE FlexibleContexts #-}