Skip to content

Instantly share code, notes, and snippets.

@yonta
yonta / fizzbuzz.sml
Last active June 20, 2019 07:33
Added FizzBuzz
(*
* A original problem is here.
* https://twitter.com/kokuyouwind/status/1141602930019061760
*)
fun fizzBuzz n =
let
val div3 = n mod 3 = 0
val div5 = n mod 5 = 0
in
@yonta
yonta / lisp-sort.el
Last active June 13, 2019 07:27
Lisp Sort
(let ((a (list 2 1)))
(sort a #'<)
a)
;; => (2)
(let ((a (list 1 2)))
(sort a #'<)
a)
;; => (1 2)
@yonta
yonta / EmacsLisp.el
Last active June 12, 2019 15:45
let-if
(let* ((a (...))
(a (if cond a (f a)))
(a (...)))
g a)
@yonta
yonta / test.el
Created May 9, 2019 12:30
test file
(defvar test-var 1)
(symbol-value 'test-var)
;; => 1
(defun f () test-var)
(symbol-function 'f)
;; => (lambda nil test-var)
(f)
@yonta
yonta / init.el
Last active April 23, 2019 23:20
;; ivy-richが提供する変数、一部省略
;; この先頭に(#'counsel-switch-buffer A)を足したい
(defcustom ivy-rich-display-transformers-list
'(ivy-switch-buffer
(...) ; A
counsel-M-x
(...)
counsel-describe-function
(...)
counsel-describe-variable
@yonta
yonta / original.md
Last active March 31, 2024 17:35
Spawn Rules of Minecraft in Bedrock Edition

Spawn cycle

Bedrock Edition

Natural spawning in Bedrock Edition shares only a few similarities to natural spawning in Java Edition. In Bedrock Edition, there are two main types of natural spawns: pack spawns and structure mob spawns. Structure mob spawns are mobs spawned as part of a structure, such as nether fortresses, witch huts, etc. Pack spawns account for all other types of natural spawns, including mobs that spawn individually (i.e. not in a pack of 2 or more). Both types of natural spawns follow the same rules for spawn conditions and the mob cap.

@yonta
yonta / int_option_minimum.sml
Last active June 7, 2018 06:09
How to get removed something and removed object, when you remove something from object in persistence data structure.
local
fun cleanHeadNone nil = nil
| cleanHeadNone (NONE :: t) = cleanHeadNone t
| cleanHeadNone (l as SOME _ :: _) = l
fun cleanEndNone l = (rev o cleanHeadNone o rev) l
fun simpleMin nil = raise Fail "Empty"
| simpleMin [NONE] = raise Fail "End with NONE"
| simpleMin [SOME x] = (x, nil)
| simpleMin (NONE :: t) = min t
| simpleMin (SOME x :: t) =
@yonta
yonta / init-env.sh
Last active May 8, 2024 13:01
Initialize environment script for WSL with Ubuntu or openSUSE
#!/bin/bash -eu
# https://qiita.com/youcune/items/fcfb4ad3d7c1edf9dc96
# -euでエラーか未定義変数でストップする
script_dir="$(cd $(dirname $0); pwd -P)"
# Color message
NORMAL=$(tput sgr0)
@yonta
yonta / arrayheader.cpp
Created February 28, 2017 06:47
C++むつかしい
/*
1. クラス内で配列データを持ちたい
2. 配列は定数長
3. 定数長値をメソッドで使いたい
4. .hは定義、.cppは本体に分けたい
*/
// .h
#define N 4 // 最終手段感
class Example1 {
@yonta
yonta / not_copy.cpp
Last active September 26, 2016 12:56
// 実際はQtのライブラリであるQTimer
// https://github.com/radekp/qt/blob/master/src/corelib/kernel/qtimer.h#L98
class DisableCopy {
public:
explicit DisableCopy(Object *parent) { // 引数ありコンストラクタ
// ...
}
private:
DISABLE_COPY(DisableCopy) // マクロでコピーが禁止されている
};