Skip to content

Instantly share code, notes, and snippets.

View lotz84's full-sized avatar

Tatsuya Hirose lotz84

View GitHub Profile
@yuu-ito
yuu-ito / _共起尺度.md
Last active June 29, 2016 01:29
共起、距離行列、内積、類似度、

共起尺度メモ

主なものとして

  • Jaccard係数
  • Simpson係数
  • コサイン距離

共起尺度、共起頻度の指標は自然言語処理関連でよく使われているらしい。

  • 文書中の単語の出現数から文書間の類似性をみるなど
@YoEight
YoEight / Dyna.hs
Last active August 2, 2022 19:44
Computes Fibonacci number with a histomorphism -- correction: Actually it's a dynamorphism as it uses an anamorphism to generate intermediary step
data Cofree f a = a :< (f (Cofree f a))
-- Fix point
newtype Mu f = Mu { unMu :: f (Mu f) }
extract :: Cofree f a -> a
extract (a :< _) = a
-- catamorphism
cata :: Functor f => (f b -> b) -> Mu f -> b
@gakuzzzz
gakuzzzz / 1_.md
Last active June 19, 2023 12:53
trait と abstract class の使い分け

trait と abstract class の使い分け

  • 基本は迷ったら trait にしておけば良いと思います
    • trait は一つの class に複数 mixin できますが、class は一つしか継承できません
    • つまり、trait であれば mixin される class を気にしなくてよいですが、 abstract class にした場合は、extends される class が他に継承したい物が無いか気にする必要があります
  • trait はコンストラクタを持つ事ができませんが、abstract class はコンストラクタを持つ事ができます
    • 従って、型引数に制約をつけたい時や、共通のフィールドの初期化などがある場合は、abstract class にすると楽な場合があります。
  • 以下に具体例を示します。良くある Java の enum を Scala で定義する場合の例です。
@gakuzzzz
gakuzzzz / 1_.md
Last active March 7, 2025 06:35
Scala の省略ルール早覚え

Scala の省略ルール早覚え

このルールさえ押さえておけば、読んでいるコードが省略記法を使っていてもほぼ読めるようになります。

メソッド定義

def concatAsString(a: Int, b: Int): String = {
  val a_ = a.toString();
  val b_ = b.toString();
@314maro
314maro / lens.md
Created May 2, 2014 09:20
Lensについて考えてた 間違ってたりしたら教えてください

Lensについて

自分用のメモという感じ

Lensの定義を見てみよう.

type Lens s t a b = forall f. Functor f => (a -> f b) -> s -> f t

Lensを作ってみよう. sforall f.の外にあっても問題ないので外に出しておこう. その方が今は都合がいい. つまりs t a b はそれぞれなんらかの型として,

@2bbb
2bbb / HelloWorld.swift
Last active August 29, 2015 14:02
HelloWorld.swift
//
// main.swift
// SwiftLine
//
// Created by ISHII 2bit on 2014/06/03.
// Copyright (c) 2014 buffer Renaiss. All rights reserved.
//
import Foundation
@staltz
staltz / introrx.md
Last active May 24, 2025 19:53
The introduction to Reactive Programming you've been missing
@gigamonkey
gigamonkey / easy.txt
Last active September 23, 2015 05:08
My first Haskell program -- it didn't work the first time it type checked but I got it there. Simple Sudoku solver based on the search part of Peter Norvig's essay about solving every Sudoku.
. 5 . | . . 1 | 4 7 9
. . 2 | 7 . . | . . 8
. . . | . 4 6 | 2 . .
------+-------+------
. 4 6 | . . 9 | 5 3 7
. . . | . 6 . | . . .
8 9 3 | 5 . . | 6 4 .
------+-------+------
. . 9 | 6 1 . | . . .
1 . . | . . 2 | 3 . .
@gakuzzzz
gakuzzzz / slide.md
Last active June 11, 2019 01:59
パターンマッチいろいろ (函数型なんたらの集い 2014 in Tokyo)

パターンマッチいろいろ

  • 2014/10/25 函数型なんたらの集い 2014 in Tokyo
  • @gakuzzzz
  • 中村 学
  • 株式会社Tech to Value
  • Scalaから来ました

参加の経緯

#! /usr/bin/env python
# -*- coding:utf-8 -*-
import concurrent.futures
import sys
import subprocess
import time
from collections import defaultdict
from data import sentences