Skip to content

Instantly share code, notes, and snippets.

View wraikny's full-sized avatar

wraikny wraikny

View GitHub Profile
[<RequireQualifiedAccess>]
module Hanoi =
open System.Collections.Generic
[<Struct>]
type Kind = Tower1 | Tower2 | Tower3
type Commands = seq<Kind * Kind>
let solve n: Commands =
@wraikny
wraikny / ApplyPattern.fsx
Last active April 20, 2023 23:16
F# Apply pattern
(*
MIT License
Copyright (c) 2023 wraikny
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
#r "nuget: FSharp.Quotations.Evaluator"
open FSharp.Quotations
open FSharp.Quotations.Evaluator
let makeSequential (xs: #seq<Expr<unit>>): Expr<unit -> unit> =
let body =
(<@ () @>)
|> Seq.foldBack(fun x s -> <@ %x; %s @>) xs
module DCont =
type DCont<'k, 'a> = ('k -> 'a)
let inline shift (f: ('b -> 'c) -> 'a): DCont<('b -> 'c), 'a> = f
type DContBuilder() =
member inline __.ReturnFrom(m): DCont<'k, 'a> = m
member inline __.Return(x): DCont<'a -> 'b, 'b> = fun k -> k x
member inline __.Bind(x: DCont<'b -> 'c, 'a>, f: 'b -> DCont<'k, 'c>): DCont<'k, 'a> =
(fun k -> x (fun g -> (f g) k))
#ifdef GL_ES
precision mediump float;
#endif
// --- Utils ---
const float PI = 3.14159265;
vec2 fromRad(float rad) {
return vec2(
cos(rad), sin(rad)
@wraikny
wraikny / hoge.command
Created August 8, 2019 06:30
mono execution shell script in OSX
#!/bin/sh
CURRENTFILEPATH=$0
cd ${CURRENTFILEPATH%/*}
FILENAME='hoge.exe'
MESSAGE_FAILLAUNCH="Failed to command: mono ./$FILENAME"
MESSAGE_FILE_NOTFOUND="Game File $FILENAME is not found."
type Model =
{
count : int
log : int list
}
// Input Kind
type Msg = Add of int | Undo
// define function
@wraikny
wraikny / SetDynamicBoneProperty.cs
Last active December 21, 2018 03:45
Dynamic Boneのプロパティ操作を楽にするやつ
using System.Collections;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
using UnityEditor.SceneManagement; //!< 追加
#endif
// 参考: https://qiita.com/sango/items/4b9035c3e75d497f91ef#_reference-00718cd16d3962c60da9
@wraikny
wraikny / name_list.rs
Last active September 1, 2018 16:18
name_list
extern crate colored;
extern crate failure;
use std::{io, fmt};
use colored::*;
fn read_line() -> Result<String, io::Error> {
let mut result = String::new();
io::stdin().read_line(&mut result)?;
Ok(result)
}