Skip to content

Instantly share code, notes, and snippets.

@mozukichi
mozukichi / Output
Last active February 9, 2024 08:39
Compare memory usage on F# program
18
18
Function 1 used 1184 bytes
Function 2 used 152 bytes
@mozukichi
mozukichi / GcdWithModulo.fs
Created January 31, 2024 04:50
逆畳み込み(unfold)による敢えて剰余の実装を含めたユークリッドのアルゴリズムの実装
let gcd u v =
Seq.unfold (fun (x, y) ->
if y = 0 then None
else
if x < y then Some ((x, y), (y, x % y))
else Some ((x - y, y), (x - y, y))
) (u, v)
|> Seq.last
|> snd
@mozukichi
mozukichi / Gcd.fs
Last active January 31, 2024 04:50
逆畳み込み(unfold)によるユークリッドのアルゴリズムの実装
let gcd u v =
Seq.unfold (fun (x, y) ->
if y = 0 then None
else Some ((x, y), (y, x % y))
) (u, v)
|> Seq.last
|> snd
@mozukichi
mozukichi / Modulo.fs
Last active January 31, 2024 04:51
逆畳み込み(unfold)による剰余の実装
let modulo u v =
(u, v) |> Seq.unfold (fun (x, y) ->
if x < y then None
else Some (x - y, (x - y, y))
) |> Seq.last
@mozukichi
mozukichi / Main.purs
Last active December 27, 2022 06:20
PureScript Hello, World!
module Main where
import Prelude
import Effect (Effect)
import Effect.Console (log)
main :: Effect Unit
main = log "Hello, World!"
@mozukichi
mozukichi / canvas-centering.css
Last active March 9, 2025 15:43
CSSによるCanvasスクリーン中央寄せ
body {
background-color: black;
margin: 0;
}
canvas {
background-color: gray;
position: absolute;
left: 50%;
margin-right: -50%;
@mozukichi
mozukichi / index.js
Created February 7, 2018 08:31
Reduxを参考にした単方向データフローによるゲームアプリケーションのソフトウェアアーキテクチャの実験経過
const createStore = (reducer, preloadedState) => {
return {
currentState: preloadedState,
getState() {
return this.currentState
},
dispatch(action) {
this.currentState = reducer(this.currentState, action)
@mozukichi
mozukichi / index.html
Created May 26, 2016 05:44
Use pixi.js on Dart
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>dart_pixijs</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pixi.js/3.0.11/pixi.min.js"></script>
<script type="application/dart" src="main.dart"></script>
<script src="packages/browser/dart.js"></script>
@mozukichi
mozukichi / main.dart
Created January 18, 2016 10:09
関数型アプローチによるゲームプログラミングのメイン処理の未来像
main() {
createDisplayObjectsStream().listen(render);
createSoundNotesStream().listen(playSoundNotes);
}
@mozukichi
mozukichi / result.txt
Last active December 16, 2015 02:22
TRHKSKのパターン一覧
たらはかさか
たらはかさき
たらはかさく
たらはかさけ
たらはかさこ
たらはかしか
たらはかしき
たらはかしく
たらはかしけ
たらはかしこ